#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;
ll cs, e, d, l, r, n, m, ans=100000000000000000, v[10000007], pref[10000007];
pair<pair<ll, ll>, ll> bans;
bool b;
int main()
{
    ios_base::sync_with_stdio(); cin.tie(); cout.tie();
    cin >> n;
    for(ll i=1; i<=n; i++)
    {
        cin >> v[i];
        pref[i]=pref[i-1]+v[i];
    }
    for(ll i=n+1; i<=n+2; i++)
    {
        v[i]=v[i-n];
        pref[i]=pref[i-1]+v[i];
    }
    if(n==3)
    {
        cout << max(v[1], max(v[2], v[3]))-min(v[1], min(v[2], v[3]));
        cout << endl << "1 2 3";
        return 0;
    }
    for(ll i=1; i<=n; i++)
    {
        if(e<i) e=i;
        while(pref[e]-pref[i]<pref[n]/3+1) e++;
        if(e<=5) d=e-1;
        else if(2*n-e<=5) d=max(2*n-e-1, 0ll);
        else d=5;
        for(ll j=e-d; j<e+d; j++)
        {
            cs=pref[j]-pref[i-1];
            l=j+1;
            r=n+i-1;
            b=(l<=r);
            while(b)
            {
            b=(l!=r);
            m=(l+r+1)/2;
            if(ans>max(cs, max(pref[m]-pref[j], pref[n]-cs-pref[m]+pref[j]))-min(cs, min(pref[m]-pref[j], pref[n]-cs-pref[m]+pref[j])))
                {
                    ans=max(cs, max(pref[m]-pref[j], pref[n]-cs-pref[m]+pref[j]))-min(cs, min(pref[m]-pref[j], pref[n]-cs-pref[m]+pref[j]));
                    bans={{i, j+1}, m+1};
                    if(m+1-n==i || m+1-n==j+1)
                    {
                        bans={{i, j+1}, m};
                    }
                }
            if(pref[m]-pref[j]>=cs)
            {
                r=m-1;
            }
            else if(l==m) l=r;
            else l=m;
            }
        }
    }
    if(pref[n]==0)
    {
        cout << 0;
        cout << endl << 1 << " " << 2 << " " << 3;
        return 0;
    }
    if(bans.first.first>n) bans.first.first-=n;
    if(bans.first.second>n) bans.first.second-=n;
    if(bans.second>n) bans.second-=n;
    cout << ans << endl;
    cout << bans.first.first << " " << bans.first.second << " " << bans.second;
}
