/*IN FISH AT EGOI I TRUST*/
/*IN FISH AT EGOI I TRUST*/
/*IN FISH AT EGOI I TRUST*/
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppl;
typedef long double ld;

mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
/*#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,popcnt")*/

ll mod,n,best,x,y,z,a[1000009],b[1000009],mi,ma;
void check(ll G,ll H,ll J,ll o){
     ll S=b[H-1]-b[G-1];
        ll T=b[J-1]-b[H-1];
        ll K=b[n]-S-T;
        if(max({S,T,K})-min({S,T,K})<best){
            best=max({S,T,K})-min({S,T,K});
            if(!o) {x=G; y=H; z=J;}
            else {
                x=n-J+1;
                y=n-H+1;
                z=n-G+1;
            }
        }
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    mod=1e15;
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++) b[i]=b[i-1]+a[i];
    best=mod; x=-1; y=-1; z=-1;
    for(int G=1;G<=n-2;G++) {
            mi=G+1; ma=G+1;
            for(int H=G+2;H<=n;H++){
                ll S=b[n]-b[H-1]+b[G-1];
                while(mi+1<H && min(b[H-1]-b[mi],S)>b[mi]-b[G-1]) mi++;
                while(ma+1<H && max(b[H-1]-b[ma],S)>b[ma]-b[G-1]) ma++;
                check(G,mi,H,0);
                check(G,ma,H,0);
                if(ma+1!=H) check(G,ma+1,H,0);
            }
    }
    reverse(a+1,a+1+n);
    for(int i=1;i<=n;i++) b[i]=b[i-1]+a[i];
    for(int G=1;G<=n-2;G++) {
            mi=G+1; ma=G+1;
            for(int H=G+2;H<=n;H++){
                ll S=b[n]-b[H-1]+b[G-1];
                while(mi+1<H &&  min(b[H-1]-b[mi],S)>b[mi]-b[G-1]) mi++;
                while(ma+1<H && max(b[H-1]-b[ma],S)>b[ma]-b[G-1]) ma++;
                check(G,mi,H,1);
                check(G,ma,H,1);
                if(ma+1!=H) check(G,ma+1,H,1);
            }
    }
    cout<<best<<"\n"<<x<<" "<<y<<" "<<z;


    return 0;
}
