#include<bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define mkp make_pair
#define pb push_back
using namespace std;
#pragma GCC optimize("O3","Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,tune=native")
int main ()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    ll a[n+2],sum[n+2];
    sum[0]=0;
    for(ll i=1; i<=n; i++)
    {
        cin>>a[i];
        sum[i]=sum[i-1]+a[i];
    }
    ll mx=1e18,ans1=0,ans2=0,ans3=0;
    for(ll x=1; x<=n; x++)
    {
        if(mx==0){break;}
        for(ll y=x+1; y<=n; y++)
        {
            if(mx==0){break;}
            ll l=y+1,r=n;
            while(l+1<r)
            {
                ll mid=(l+r)/2;
                ll q=sum[y-1]-sum[x-1],q2=sum[mid-1]-sum[y-1],q3=sum[n]-sum[mid-1]+sum[x-1];
                ll res=max({q,q2,q3})-min({q,q2,q3});
                if(res==0){l=mid; break;}
                if(res>0){l=mid+1; }
                else{r=mid-1;}
            }
            ll q=sum[y-1]-sum[x-1],q2=sum[l-1]-sum[y-1],q3=sum[n]-sum[l-1]+sum[x-1];
            ll res=max({q,q2,q3})-min({q,q2,q3});
            //cout<<x<<' '<<y<<' '<<l<<'\n';
            if(res==0){ans1=x; ans2=y; ans3=l; mx=0; break;}
        }
    }
    cout<<mx<<'\n'<<ans1<<' '<<ans2<<' '<<ans3;

}
