#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define el '\n'
#define ff first
#define ss second
#define pb push_back
#define point pair <ll, ll>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

const ll N = 1e6 + 10;
const ll inf = 1e18 + 10;

ll a[N], b[N], pref[N];

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

    ll n;
    cin >> n;

    ll total = 0;
    for (ll i = 0; i < n; i++)
        cin >> a[i], total += a[i];

    ll cur = 0, ind = -1, step = 0;
    for (ll i = 0; i < n; i++) {
        while (cur < total / 3) {
            cur += a[ind + 1];
            ind++;
        }

        if (cur == total / 3) {
            step = i;
            ll last = 0;
            for (ll j = i; j < n; j++)
                b[last++] = a[j];
            for (ll j = 0; j < i; j++)
                b[last++] = a[j];
            break;
        }
        cur -= a[i];
    }

    for (ll i = 0; i < n; i++)
        a[i] = b[i];

    ll ans = inf, way[3];

    auto get = [&](ll x, ll y) -> ll {
        x++, y++;
        ll mx = max({pref[x], pref[y] - pref[x], pref[n] - pref[y]});
        ll mn = min({pref[x], pref[y] - pref[x], pref[n] - pref[y]});
        return mx - mn;
    };

    for (ll j = 1; j <= n; j++)
        pref[j] = pref[j - 1] + a[j - 1];

    bool ok = 0;
    for (ll i = 1; i <= n; i++)
        ok |= pref[i] == total / 3;
    assert(ok);

    ll id = 1;
    for (ll j = 0; j < n - 2; j++) {
        id = max(id, j + 1);
        ll want = (pref[n] - pref[j + 1]) / 2;

        while (id + 1 < n - 1 && pref[n] - pref[id + 1] > want)
            id++;

        if (ans > get(j, id)) {
            ans = get(j, id);
            way[0] = (id + 1 + step) % n, way[1] = (j + 1 + step) % n, way[2] = step;
        }
        if (id - 1 > j && ans > get(j, id - 1)) {
            ans = get(j, id - 1);
            way[0] = (id + step) % n, way[1] = (j + 1 + step) % n, way[2] = step;
        }
    }

    cout << ans << el;
    sort(way, way + 3);
    for (ll i = 0; i < 3; i++)
        cout << way[i] + 1 << " ";
    cout << el;

    return 0;
}
