#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define endl '\n'

vector<ll> a, pref;
ll n, s = 0;

pair<ll, vector<ll>>  get(ll l, ll r){
    ll ans = (ll)(1e18);
    vector<ll> res = {l, r + 1, r + 2};
    ll cur = pref[r] - (l != 0 ? pref[l - 1] : 0);
    ll left0 = n - (r - l + 1);

    ll bl = r + 1, br = r + left0 - 1;

    while(bl < br){
        ll mid = (bl + br + 1) >> 1;

        ll s1 = pref[mid] - pref[r];
        ll s2 = s - cur - s1;

        ll delta = s1 - s2;
        if(delta <= 0)
            bl = mid;
        else
            br = mid - 1;
    }

    for(int check = max((ll)r + 1, bl - 3); check <= min((ll)r + left0 - 1, bl + 3); check++){
        ll s1 = pref[check] - pref[r];
        ll s2 = s - cur - s1;

        ll cnt = max({abs(s1 - cur), abs(s1 - s2), abs(cur - s2)});

        if(cnt < ans){
            ans = cnt;

            res = {l, r + 1, check + 1};

            if(check + 1 >= n){
                ll other_end = check - n + 1;
                res = {other_end, l, r + 1};
            }
        }
    }

    return {ans, res};
}

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

    cin >> n;

    a.resize(n);
    for(auto &i: a)
        cin >> i;

    for(auto i: a)
        s += i;

    ll need = s / 3;

    for(int i = 0; i < n; i++)
        a.push_back(a[i]);

    pref.resize(2 * n);
    pref[0] = a[0];

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

    ll ans = (ll)(1e18);
    vector<ll> res = {1, 2, 3};

    ll can = s / 3;
    ll cur = 0;

    for(int i = 0; i < n; i++){
        cur += a[i];

        if(cur == can){
            ll can2 = can;
            if(can2 + can > s)
                can2--;

            cur = 0;

            for(int j = i + 1; j < n; j++){
                cur += a[j];

                if(cur == can2){
                    ll s1 = pref[i], s2 = pref[j] - pref[i];
                    ll s3 = s - s1 - s2;

                    ans = max({s1, s2, s3}) - min({s1, s2, s3});
                    res = {0, i + 1, j + 1};
                    break;
                }
            }

            break;
        }
    }

    cout << ans << endl;
    for(auto i: res)
        cout << i + 1 << ' ';
    cout << endl;

    return 0;
}

/*
1
2
1 2 3
3 4 5

1
5
1 2 1
1 3 4
4 5 2
3 4 2
1 4 3

4
1 2 3
2 3 4
3 5 4
1 3 2

*/
