#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;
    vector<int> a(n);
    for (auto &i : a) cin >> i;
    vector<ll> p(n + n + 1);
    for (int i = 0; i < (int)p.size() - 1; i ++) {
        p[i + 1] = p[i] + a[i % n];
    }
    vector<int> pr(n + n + 1);
    int re = 0;
    ll ts = 0;
    for (int i = 0; i < n + n; i ++) {
        ts += a[i % n];
        while (ts > p[n] / 3) {
            ts -= a[re % n];
            re ++;
        }
        pr[i] = re;
    }
    /*for (int i = n; i < n + n; i ++) {
        cout << pr[i] % n << " ";
    }
    cout << endl;*/
    long long _r = LLONG_MAX / 2;
    int _a, _b, _c;
    for (int i = 0; i < n; i ++) {
        for (int l1 = -2; l1 < 4; l1 ++) {
            int pt = (pr[i + n] - l1 + n) % n;
            for (int l2 = -2; l2 < 4; l2 ++) {
                int o0 = i, o1 = pt;
                int o2 = (pr[pt + n] - l2 + n) % n;
                //cout << o0 << " " << o1 << " " << o2 << endl;
                #define S(X, Y) if (X < Y) swap(X, Y);
                S(o2, o1) S(o1, o0)
                S(o2, o1) S(o1, o0)
                S(o2, o1) S(o1, o0)
                {
                ll x = p[o1] - p[o0];
                ll y = p[o2] - p[o1];
                ll z = p[n] - x - y;
                ll t = max({x, y, z}) - min({x, y, z});
                if (o0 != o1 && o1 != o2 && o2 != o0 && _r > t) {
                    _r = t;
                    _a = o0 + 1;
                    _b = o1 + 1;
                    _c = o2 + 1;
                }
                }
            }
        }
    }
    cout << _r << "\n" << _a << " " << _b << " " << _c << endl;
}
