#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
const ll SIZ = ((ll)7e5 + 5), LONGBOI = ((ll)1e17 + 5);
mt19937_64 REALrandom(chrono::system_clock::to_time_t(chrono::system_clock::now()));

struct mycompare{
    bool operator()(ll a, ll b) const{
        return a%10 > b%10;
    }
};

struct str{
    ll n;
};

bool operator < (str a, str b){
    return a.n < b.n;
}

ll n;
ll a[SIZ],p[SIZ];

ll Check(ll &st, ll &s1, ll &s2){
    ll s3=n-s1-s2;
    //cout << "CHECK : start = " << st << " s1 = " << s1 << " s2 = " << s2 << " s3 = " << s3 << " and ans = ";
    if(s3<=0||s2<=0||s1<=0) {
        //cout<<LONGBOI<<endl;
        return LONGBOI;
    }
    ll sum1=0, sum2=0, sum3=0;
    ll pos=st;

    if(pos+s1-1<=n){
        sum1=p[pos+s1-1]-p[pos-1];
        pos+=s1;
    }
    else{
        sum1=p[n]-p[pos-1]+p[pos+s1-1-n];
        pos+=s1; pos-=n;
    }

    if(pos+s2-1<=n){
        sum2=p[pos+s2-1]-p[pos-1];
        pos+=s2;
    }
    else{
        sum2=p[n]-p[pos-1]+p[pos+s2-1-n];
        pos+=s2; pos-=n;
    }

    if(pos+s3-1<=n){
        sum3=p[pos+s3-1]-p[pos-1];
        pos+=s3;
    }
    else{
        sum3=p[n]-p[pos-1]+p[pos+s3-1-n];
        pos+=s3; pos-=n;
    }

    ll mx=max(sum1, max(sum2,sum3));
    ll mn=min(sum1, min(sum2,sum3));
    //cout << mx-mn << " because sum1 = " << sum1 << " sum2 = " << sum2 << " sum3 = " << sum3 << endl;
    return mx-mn;
}

pll Search2(ll &st, ll &s1){
    ll l=1, r=n-s1+1;
    ll tml, tmr, al, ar;
    while(l+1<r){
        //cout << "Search2 : l = " << l << " r = " << r << endl;
        tml = l + (r-l+1)/3; al = Check(st, s1, tml);
        tmr = r - (r-l+1)/3; ar = Check(st, s1, tmr);
        if(al < ar || (al == ar && al == LONGBOI)) r = tmr;
        else l = tml;
    }
    //cout << "Search2 ended : st = " << st << " s1 = " << s1 << " s2 = " << l << endl;
    al = Check(st, s1, l);
    return {al, l};
}

pll Search1(ll &st){
    ll l=1, r=n+1;
    ll tml, tmr, al, ar;
    while(l+1<r){
        //cout << "Search1  : l = " << l << " r = " << r << endl;
        tml = l + (r-l+1)/3; al = Search2(st, tml).first;
        tmr = r - (r-l+1)/3; ar = Search2(st, tmr).first;
        if(al < ar || (al == ar && al == LONGBOI)) r = tmr;
        else l = tml;
    }
    //cout << "Search1 ended : st = " << st << " s1 = " << l << endl;
    al = Search2(st, l).first;
    return {al, l};
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("output.txt", "w", stdout);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        p[i]=p[i-1]+a[i];
    }
    ll ans=LONGBOI;
    pll res;
    ll st, s1, s2, s3;
    for(ll i=1;i<=n;i++){
        res = Search1(i);
        if(res.first < ans){
            //cout << "------------------------------------------NEW ANS------------------------------------------" << endl;
            ans = res.first;
            st = i;
            s1 = res.second;
            res = Search2(i, s1);

            s2 = res.second;
            s3 = n - s1 - s2;
            //cout << "------------------------------------------NEW ANS ENDED------------------------------------------" << endl;
            if(ans == 0) break;
        }
    }
    ll p1, p2, p3;
    ll pos=st;

    p1 = pos;
    pos += s1;
    if(pos > n) pos -= n;

    p2 = pos;
    pos += s2;
    if(pos > n) pos -= n;

    p3 = pos;
    pos += s3;
    if(pos > n) pos -= n;

    if(p3 < p2) swap(p2, p3);
    if(p2 < p1) swap(p1, p2);

    cout << ans << endl;
    cout << p1 << " " << p2 << " " << p3 << endl;
    //cout << "Start = " << st << " Sizes : " << s1 << " " << s2 << " " << s3 << endl;
    return 0;
}
