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

int n;
vector<ll> a, ps;
vector<vector<ll>> bin;

int conv(int i) {
    if (i < 0) {
        return n + i;
    }
    return i % n;
}

pair<pair<ll, ll>, ll> fn(ll a, ll i) {
    ll sm = 0;
    ll cnt = 0;
    if (ps[n] - ps[i] <= a) {
        cnt += n - i;
        sm = ps[n] - ps[i];
        i = 0;
    }
    for (int lv = 29; lv >= 0; lv--) {
        ll nx = i + (1 << lv);
        if (nx > n || sm + bin[lv][i] > a) {
            continue;
        }
        sm += bin[lv][i];
        i += 1 << lv;
        cnt += 1 << lv;
    }
    return {{sm, cnt}, i};
}

int main() {
    freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    vector<ll> a(n);
    a.resize(n);
    ps.resize(n + 1);
    bin.resize(30, vector<ll>(n));
    ll sma = 0;
    for (auto& el : a) {
        cin>>el;
        sma += el;
    }
    if (sma == 0) {
        cout << 0 << endl;
        cout << 1 << " " << 2 << " " << 3 << endl;
        return 0;
    }
    for (int i = 0; i < n;i++) {
        ps[i + 1] = ps[i] + a[i];
        bin[0][i] = a[i];
    }
    for (int lv = 1; lv < 30; lv++) {
        for (int i = 0; i < n;i++) {
            int nx = i + (1 << (lv - 1));
            if (nx >= n) {
                bin[lv][i] = bin[lv - 1][i];
            }
            else {
                bin[lv][i] = bin[lv - 1][i] + bin[lv - 1][nx];
            }
        }
    }
    ll res = 1e18;
    ll tk = sma / 3;
    vector<ll> ans;
    int a1 = -1;
    int b = -1;
    int c = -1;
    for (int st = 0; st < n; st++) {
        // int ind = st;
        auto [pr, ind] = fn(tk, st);
        auto [sm, cnt] = pr;
        // cout << st << " " << ind << " " << sm << " " << cnt << endl;
        // ll sm = 0;
        int lft = n - cnt;
        // while (lft > 2 && sm < tk) {
        //     sm += a[ind];
        //     ind++;
        //     lft--;
        //     ind %= n;
        // }
        sm -= a[ind - 1];
        vector<ll> sc = {ind - 1, ind};
        for (int z = 0; z < sc.size(); z++) {
            if (sc[z] <= st) {
                sm += a[sc[z]];
                continue;
            }
            auto [ppr, j] = fn(tk, sc[z]);
            auto [cs, cnnt] = ppr;
            // cout << sm << " " << cs << " " << j << " " << st << endl;
            // if (st == 2) {
            //     cout << sc[z] << " " << j << " " << cs << endl;
            // }
            if (j == st) {
                j = conv(j - 1);
                cs -= a[j];
            }
            if (j == sc[z]) {
                cs += a[j];
                j = conv(j + 1);
            }
            ll vl = max(sm, max(cs, sma - sm - cs)) - min(sm, min(cs, sma - sm - cs));
            if (vl < res) {
                ans = {st, sc[z], j};
                res = vl;
            }
            sm += a[sc[z]];
        }
    }
    cout << res << endl;
    // cout << 1 << " " << 2 << " " << 3 << endl;
    // return 0;
    sort(ans.begin(), ans.end());
    for (auto& el : ans) {
        cout << el + 1 << " ";
    }
    cout << endl;
}