#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<ll, int> fn(ll a, int i) {
    ll sm = 0;
    int cnt = 0;
    if (ps[n] - ps[i] <= a) {
        cnt += n - i;
        sm = ps[n] - ps[i];
        i = 0;
    }
    for (int lv = 20; 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, 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(21, 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 < 21; 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<int> ans;
    int a1 = -1;
    int b = -1;
    int c = -1;
    vector<pair<ll, int>> fns(n);
    int j = 0;
    ll csm = 0;
    for (int i = 0; i < n;i++) {
        while (csm <= tk) {
            csm += a[j];
            j = conv(j + 1);
        }
        // fns[i] = {csm, j};
        fns[i] = fn(tk, i);
        csm -= a[i];
    }
    for (int st = 0; st < n; st++) {
        auto [sm, ind] = fns[st];
        sm -= a[ind - 1];
        vector<int> sc = {ind - 1, ind, conv(ind + 1)};
        for (int z = 0; z < sc.size(); z++) {
            if (sc[z] <= st) {
                sm += a[sc[z]];
                continue;
            }
            auto [cs, j] = fns[sc[z]];
            if (j == st) {
                j = conv(j - 1);
                cs -= a[j];
            }
            if (j == sc[z]) {
                cs += a[j];
                j = conv(j + 1);
            }
            vector<int> sc2 = {j, conv(j + 1)};
            for (int v = 0; v < sc2.size(); v++) {
                ll vl = max(sm, max(cs, sma - sm - cs)) - min(sm, min(cs, sma - sm - cs));
                if (vl < res) {
                    a1 = st;
                    b = sc[z];
                    c = sc2[v];
                    res = vl;
                }
                cs += a[sc2[v]];
            }
            ll vl = max(sm, max(cs, sma - sm - cs)) - min(sm, min(cs, sma - sm - cs));
            if (vl < res) {
                res = vl;
                a1 = st;
                b = sc[z];
                c = j;
                res = vl;
            }
            sm += a[sc[z]];
        }
    }
    cout << res << endl;
    ans.push_back(a1);
    ans.push_back(b);
    ans.push_back(c);
    sort(ans.begin(), ans.end());
    for (auto& el : ans) {
        cout << el + 1 << " ";
    }
    cout << endl;
}