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

int n;

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

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);
    ll sma = 0;
    for (auto& el : a) {
        cin>>el;
        sma += el;
    }
    ll res = 1e18;
    ll tk = sma / 3;
    int a1 = -1;
    int b = -1;
    int c = -1;
    for (int st = 0; st < n; st++) {
        int ind = st;
        ll sm = 0;
        int lft = n;
        while (lft > 2 && sm < tk) {
            sm += a[ind];
            ind++;
            lft--;
            ind %= n;
        }
        vector<int> sc = {conv(ind - 1), ind, conv(ind + 1)};
        for (int z = 0; z < sc.size(); z++) {
            int nlft = lft;
            int j = sc[z];
            ll cs = 0;
            while (nlft > 1) {
                cs += a[j];
                j++;
                j %= n;
                nlft--;
                ll vl = max(sm, max(cs, sma - sm - cs)) - min(sm, min(cs, sma - sm - cs));
                // cout << st << " " << sc[z] << " " << vl << " " << cs << " " << sm << endl;
                if (vl < res) {
                    res = vl;
                    a1 = st;
                    b = sc[z];
                    c = j;
                }
            }
        }
    }
    cout << res << endl;
    cout << a1 + 1 << " " << b + 1 << " " << c + 1 << endl;
}
