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

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

    int n; cin>>n; int a[2*n+1]; for (int i=1; i<=n; i++) cin>>a[i];
    for (int i=n+1; i<=2*n; i++) a[i] = a[i-n];

    long long s=0;
    for (int i=1; i<=n; i++) s+=a[i];
    long long s1 = s/3;
    long long pref[2*n+1]; pref[0]=0;
    for (int i=1; i<=2*n; i++) pref[i] = pref[i-1]+a[i];

int ans1, ans2, ans3;
int ans=1e9;

    for (int shift=0; shift<n; shift++) {
        int target = s1+pref[shift];
        int x = lower_bound(pref, pref+2*n, target) - pref;
        int target2 = 2*s1+pref[shift];
        int y = lower_bound(pref, pref+2*n, target2) - pref;
        long long seg1 = pref[y]-pref[x], seg2 = pref[x]-pref[shift], seg3 = s - seg1 - seg2;
        long long ans_cur = max(abs(seg1-seg2), abs(seg2-seg3));
        ans_cur = max (ans_cur, abs(seg1-seg3));
        if (ans_cur<ans) {
            ans = ans_cur;
            ans1 = shift; ans2 = x; ans3=y;
        }
        //cout<<"seg:   "<<seg1<<' '<<seg2<<' '<<seg3<<"\n";
        //cout<<target<<' '<<pref[x]<<' '<<target2<<' '<<pref[y]<<"\n";
    }

    cout<<ans<<"\n";
    cout<<ans1+1<<' '<<ans2+1<<' '<<ans3+1;

}
