#include <bits/stdc++.h>

using namespace std;

/*
if(used[to]) low[v]=min(low[v],tin[to])
else{
    dfs(to,v);
    low[v]=min(low[v],low[to]);

    if(low[to]>tin[v]) rebro;
}*/
#define ll long long
struct sr{ll zn;int x,y,z;};

const int N=1e6;

ll a[N],pr[N],sum;
int n,x;
sr vid={1000000000000000000,0,0,0};



void per2(ll prs,ll L,ll R){

    int l=L,r=R-1,mid;

    while(l<r){
        mid=(l+r+1)>>1;

        if(pr[mid]-pr[L-1]<=sum) l=mid;
        else r=mid-1;
    }

    ll e=max({prs,pr[l]-pr[L-1],pr[R]-pr[l]})-min({prs,pr[l]-pr[L-1],pr[R]-pr[l]});

    if(e<vid.zn){
        vid={e,x,(L>n?L-n:L),(L+1>n?L+1-n:L+1)};
    }

    if(l+1!=R){

        e=max({prs,pr[l+1]-pr[L-1],pr[R]-pr[l+1]})-min({prs,pr[l+1]-pr[L-1],pr[R]-pr[l+1]});
        if(e<vid.zn) vid={e,x,(L>n?L-n:L),(l+2>n?l+2-n:l+2)};
    }
}

void per1(ll L,ll R){

    int l=L,r=R-2,mid;

    while(l<r){
        mid=(l+r+1)>>1;

        if(pr[mid]-pr[L-1]<=sum) l=mid;
        else r=mid-1;
    }

   // cout<<L<<" "<<l<<"\n";

    per2(pr[l]-pr[L-1],l+1,R);
    if(l+1!=R-1) per2(pr[l+1]-pr[L-1],l+2,R);

}


void solve(){

    cin>>n;

    for(int i=1;i<=n;++i) cin>>a[i],a[i+n]=a[i],sum+=a[i];
    for(int i=1;i<=n*2;++i) pr[i]=pr[i-1]+a[i];
   // for(ll i=1;i<=n*2;++i) cout<<pr[i]<<" ";
  //  cout<<"\n";
    sum/=3;

    for(ll i=1;i<=n;++i) x=i,per1(i,i+n-1);
    cout<<vid.zn<<"\n"<<vid.x<<" "<<vid.y<<" "<<vid.z<<"\n";
}

int main()
{
    ll q=1;
   // cin>>q;
    while(q--) solve();
}
