#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
using namespace std;
struct node{ll first, second, third;};
void solve(){
    ll n;
    cin >> n;
    vector<ll> values;
    vector<ll> positions;
    for(ll i = 0; i<n; i++){
        ll value;
        cin >> value;
        positions.push_back(i+1);
        values.push_back(value);
    }
    for(ll i = 0; i<n-1; i++){ values.push_back(values[i]); positions.push_back(i+1);}
    ll m = n+n-1;
    ll pref[m];
    pref[0]=values[0];
    for(ll i = 1; i<m; i++) pref[i]=pref[i-1]+values[i];
    ll answer = 1e18;
    node ans;
    ans.first=1e18;
    ans.second=1e18;
    ans.third=1e18;
    for(ll i = 0; i<n; i++){
        for(ll j = i+1; j<=i+n-2; j++){
            ll have = pref[j-1];
            if(i!=0) have-=pref[i-1];
            ll whole = pref[i+n-1];
            if(i!=0) whole-=pref[i-1];
            ll left = j, right = i+n-2;
            ll rem = 1e18;
            ll last = 1e18;
            //ll counter = 0;
            while(left<=right){
                //counter++;
                //cout << left << ' ' << right << '\n';
                ll middle = (left+right)/2;
                ll dif = -pref[j-1];
                dif+=pref[middle];
                ll other = whole-have-dif;
                if(dif>=have && other<=dif){
                    rem=dif;
                    last = middle;
                    right=middle-1;
                }
                else left=middle+1;
                //cout << middle << '\n';
                //cout << left << ' ' << right << '\n';
                //if(counter==100) break;
            }
            ll so = whole-have-rem;
            if(last==1e18 || so<have) continue;
            if(answer>rem-have){
                answer=rem-have;
                ans.first=positions[i];
                ans.second=positions[j];
                ans.third=positions[last+1];
            }
        }
    }
    reverse(positions.begin(), positions.end());
    reverse(values.begin(), values.end());
    pref[0]=values[0];
    for(ll i = 1; i<m; i++) pref[i]=pref[i-1]+values[i];
    for(ll i = 0; i<n; i++){
        for(ll j = i+1; j<=i+n-2; j++){
            ll have = pref[j-1];
            if(i!=0) have-=pref[i-1];
            ll whole = pref[i+n-1];
            if(i!=0) whole-=pref[i-1];
            ll left = j, right = i+n-2;
            ll rem = 1e18;
            ll last = 1e18;
            //ll counter = 0;
            while(left<=right){
                //counter++;
                //cout << left << ' ' << right << '\n';
                ll middle = (left+right)/2;
                ll dif = -pref[j-1];
                dif+=pref[middle];
                ll other = whole-have-dif;
                if(dif>=have && other<=dif){
                    rem=dif;
                    last = middle;
                    right=middle-1;
                }
                else left=middle+1;
                //cout << middle << '\n';
                //cout << left << ' ' << right << '\n';
                //if(counter==100) break;
            }
            ll so = whole-have-rem;
            if(last==1e18 || so<have) continue;
            if(answer>rem-have){
                answer=rem-have;
                ans.first=positions[i];
                ans.second=positions[j];
                ans.third=positions[last+1];
            }
        }
    }
    if(ans.first>ans.second) swap(ans.first, ans.second);
    if(ans.second>ans.third) swap(ans.second, ans.third);
    if(ans.first>ans.second) swap(ans.first, ans.second);
    cout << answer << '\n';
    cout << ans.first << ' ' << ans.second << ' ' << ans.third << '\n';
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    freopen("input.txt", "r", stdin);
    ll tests;
    tests=1;
    while(tests--) solve();
}