#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(rand()%2==1){continue;}
        if(mx==0){break;}
        for(ll y=x+1; y<=n; y++)
        {
            if(mx==0){break;}
            for(ll z=y+1; z<=n; z++)
            {
                ll q=sum[y-1]-sum[x-1],q2=sum[z-1]-sum[y-1],q3=sum[n]-sum[z-1]+sum[x-1];
                ll res=max({q,q2,q3})-min({q,q2,q3});
                if(q!=q2 && q2==max({q,q2,q3}) && q==min({q,q2,q3})){break;}
                if(q!=q2 && q==max({q,q2,q3}) && q2==min({q,q2,q3})){break;}
                if(mx>res){mx=res; ans1=x; ans2=y; ans3=z;}
                if(mx==0){break;}
            }
        }
    }
    cout<<mx<<'\n'<<ans1<<' '<<ans2<<' '<<ans3;

}
