#include <bits/stdc++.h>
#define int long long
using namespace std;

struct ans{
    int a,b,c,d;
};

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin>>n;
    int a[n];
    int tsm = 0;
    for(int i = 0;i<n;i++){
        cin>>a[i];
        tsm += a[i];
    }
    int pr[n+1];
    pr[0] = 0;
    for(int i = 1;i<=n;i++){
        pr[i] = pr[i-1]+a[i-1];
    }
    ans ans1;
    ans1.d = 1e18;
    for(int i = 0;i<n-2;i++){
        int ps = i+1;
        for(int j = i+2;j<n;j++){
            /*
            for(int k = i+1;k<j;k++){
                int sm = pr[i]+pr[n]-pr[j];
                int sm1 = pr[k]-pr[i];
                int sm2 = pr[j]-pr[k];
                if(max(sm,max(sm1,sm2))-min(sm,min(sm1,sm2)) < ans1.d){
                    ans1.d = max(sm,max(sm1,sm2))-min(sm,min(sm1,sm2));
                    ans1.a = i;
                    ans1.b = k;
                    ans1.c = j;
                }
            }
            */
            while(ps < j-1 && abs((pr[ps]-pr[i])-(pr[j]-pr[ps])) >= abs((pr[ps+1]-pr[i])-(pr[j]-pr[ps+1]))){
                ps++;
            }
            int sm = pr[i]+pr[n]-pr[j];
            int sm1 = pr[ps]-pr[i];
            int sm2 = pr[j]-pr[ps];
            //cout<<i<<' '<<ps<<' '<<j<<' '<<sm<<' '<<sm1<<' '<<sm2<<endl;
            if(max(sm,max(sm1,sm2))-min(sm,min(sm1,sm2)) < ans1.d){
                ans1.d = max(sm,max(sm1,sm2))-min(sm,min(sm1,sm2));
                ans1.a = i;
                ans1.b = ps;
                ans1.c = j;
            }
            if(ps != i+1){
                ps--;
                sm = pr[i]+pr[n]-pr[j];
                sm1 = pr[ps]-pr[i];
                sm2 = pr[j]-pr[ps];
                //cout<<i<<' '<<ps<<' '<<j<<' '<<sm<<' '<<sm1<<' '<<sm2<<endl;
                if(max(sm,max(sm1,sm2))-min(sm,min(sm1,sm2)) < ans1.d){
                    ans1.d = max(sm,max(sm1,sm2))-min(sm,min(sm1,sm2));
                    ans1.a = i;
                    ans1.b = ps;
                    ans1.c = j;
                }
            }
        }
    }
    cout<<ans1.d<<endl;
    cout<<ans1.a+1<<' '<<ans1.b+1<<' '<<ans1.c+1;
}
