#include <bits/stdc++.h>
using namespace std;
int n, l, r, l2, r2, mid, x, y, z;
long long summ, one, a, ans = 1e18;
vector<long long> A(1), Pref(1);
vector<int> Ans(3);
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        A.push_back(a);
        Pref.push_back(Pref[i] + a);
    }
    summ = Pref[n];
    for (int i = 1; i <= n; ++i) {
        l = i - 1; r = n + i;
        while (l < r - 1) {
            mid = (l + r) / 2;
            if (Pref[mid] - Pref[i - 1] <= summ / 3) l = mid;
            else r = mid;
        }
        if (l != i - 1) {
            one = Pref[l] - Pref[i - 1];
            l2 = l; r2 = n + i;
            while (l2 < r2 - 1) {
                mid = (l2 + r2) / 2;
                if (Pref[mid] - Pref[l] <= summ / 3) l2 = mid;
                else r2 = mid;
            }
            if (l2 != l && ans > max(one, max(Pref[l2] - Pref[l], Pref[n + i - 1] - Pref[l2])) - min(one, min(Pref[l2] - Pref[l], Pref[n + i - 1] - Pref[l2]))) {
                ans = max(one, max(Pref[l2] - Pref[l], Pref[n + i - 1] - Pref[l2])) - min(one, min(Pref[l2] - Pref[l], Pref[n + i - 1] - Pref[l2]));
                x = i; y = l + 1; z = l2 + 1;
            }
            if (r2 != n + i && ans > max(one, max(Pref[r2] - Pref[l], Pref[n + i - 1] - Pref[r2])) - min(one, min(Pref[r2] - Pref[l], Pref[n + i - 1] - Pref[r2]))) {
                ans = max(one, max(Pref[r2] - Pref[l], Pref[n + i - 1] - Pref[r2])) - min(one, min(Pref[r2] - Pref[l], Pref[n + i - 1] - Pref[r2]));
                x = i; y = l + 1; z = r2 + 1;
            }
        }
        if (r != n + i) {
            one = Pref[r] - Pref[i - 1];
            l2 = r; r2 = n + i;
            while (l2 < r2 - 1) {
                mid = (l2 + r2) / 2;
                if (Pref[mid] - Pref[r] <= summ / 3) l2 = mid;
                else r2 = mid;
            }
            if (l2 != r && ans > max(one, max(Pref[l2] - Pref[r], Pref[n + i - 1] - Pref[l2])) - min(one, min(Pref[l2] - Pref[r], Pref[n + i - 1] - Pref[l2]))) {
                ans = max(one, max(Pref[l2] - Pref[r], Pref[n + i - 1] - Pref[l2])) - min(one, min(Pref[l2] - Pref[r], Pref[n + i - 1] - Pref[l2]));
                x = i; y = r + 1; z = l2 + 1;
            }
            if (r2 != n + i && ans > max(one, max(Pref[r2] - Pref[r], Pref[n + i - 1] - Pref[r2])) - min(one, min(Pref[r2] - Pref[r], Pref[n + i - 1] - Pref[r2]))) {
                ans = max(one, max(Pref[r2] - Pref[r], Pref[n + i - 1] - Pref[r2])) - min(one, min(Pref[r2] - Pref[r], Pref[n + i - 1] - Pref[r2]));
                x = i; y = r + 1; z = r2 + 1;
            }
        }
        Pref.push_back(Pref[Pref.size() - 1] + A[i]);
    }
    cout << ans << "\n";
    if (x <= n) Ans[0] = x; else Ans[0] = x - n;
    if (y <= n) Ans[1] = y; else Ans[1] = y - n;
    if (z <= n) Ans[2] = z; else Ans[2] = z - n;
    sort(Ans.begin(), Ans.end());
    cout << Ans[0] << " " << Ans[1] << " " << Ans[2];
}