#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,x,y,z;};

const ll N=2e5;

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


ll f(ll t){
    return (t>n?t-n:t);
}

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

    ll l=L,r=R-1;

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

        ll sumpr=pr[mid]-pr[L-1];

        if(sumpr<=sum) l=mid;
        else r=mid-1;
    }

    ll sumy=pr[l]-pr[L-1],sumz=pr[R]-pr[l];

    ll e=max({prs,sumy,sumz})-min({prs,sumy,sumz});



  //  cout<<x<<" "<<f(L)<<" "<<f(l+1)<<" "<<e<<"\n\n";
  //  cout<<prs<<" "<<sumy<<" "<<sumz<<" "<<R<<"\n\n";
    if(e<vid.zn){
        vid={e,x,f(L),f(l+1)};
    }

    if(l+1!=R){
        l++;
    sumy=pr[l]-pr[L-1],sumz=pr[R]-pr[l];

    e=max({prs,sumy,sumz})-min({prs,sumy,sumz});

  //  cout<<x<<" "<<f(L)<<" "<<f(l+1)<<" "<<e<<"\n\n";

        if(e<vid.zn){
        vid={e,x,f(L),f(l+1)};
        }
    }
}

void per1(ll L,ll R){

    ll l=L,r=R-2;

    while(l<r){
        ll mid=(l+r+1)>>1;
        ll sumpr=pr[mid]-pr[L-1];

        if(sumpr<=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(ll i=1;i<=n;++i) cin>>a[i],a[i+n]=a[i],sum+=a[i];
    for(ll 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();
}
