#include <bits/stdc++.h>
using namespace std;
int sma=0,n;
vector<int> ans(4),ans2(4),a;
void aa(int l0)
{
    int l=l0,t=l0,sm=0;
    while(sm!=sma/3 && t<n)
    {
        if(sm<sma/3){
            sm+=a[t];
            t++;
        }else{
            sm-=a[l];
            l++;
        }
    }
    int sm2=0,t2=t;
    while(sm2<sma/3)
    {
        t2=t2%n;
        sm2+=a[t2];
        t2=(t2+1);
    }
    ans2={max({sm,sm2,sma-sm-sm2})-min({sm,sm2,sma-sm-sm2}),l,t,t2};
}
int main(){
    cin>>n;
    a.resize(n);
    for(int i=0;i<n;i++){cin>>a[i];sma+=a[i];}
    aa(0);
    ans=ans2;
    int l=ans[1]+1;
    while(ans[0]>0)
    {
        aa(l);
        l=ans2[1]+1;
        if(ans2[0]<ans[0])ans=ans2;
    }
    cout<<ans[0]<<endl<<ans[1]<<' '<<ans[2]<<' '<<ans[3];
}