#include <iostream>
#include <vector>
#include <climits>

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int i, n, t, l, r, j, sum1, sum2, sum3, p1, p2, res = INT_MAX, s1 = 0, s2 = 0, s3 = 0;
    vector<int> cycle;
    bool smthChanged = 0, test = 0;
    cin >> n;
    for (i = 0; i < n; i++) {
        cin >> t;
        cycle.push_back(t);
    }
    for (i = 0; i < n; i++) {
        cycle.push_back(cycle[i]);
    }
    for (i = 0; i <= n; i++) {
        l = i, r = n + i;
        p1 = l + 1;
        p2 = l + 2;
        sum1 = cycle[l];
        sum2 = cycle[p1];
        sum3 = 0;
        for (j = p2; j < r; j++) {
            sum3 += cycle[j];
        }
        smthChanged = true;
        while (smthChanged) {
            smthChanged = false;
            if (res > max(sum1, max(sum2, sum3)) - min(sum1, min(sum2, sum3))) {
                res = max(sum1, max(sum2, sum3)) - min(sum1, min(sum2, sum3));
                s1 = max((i + 1) % (n + 1), 1), s2 = max((p1 + 1) % (n + 1), 1), s3 = max((p2 + 1) % (n + 1), 1);
                if (res == 0) {
                    cout << res << endl;
                    cout << min(s1, min(s2, s3)) << " " << s1 + s2 + s3 - min(s1, min(s2, s3)) - max(s1, max(s2, s3)) << " " << max(s1, max(s2, s3));
                    return 0;
                }
            }
            if (sum1 < sum2 && p1 + 1 != p2) {
                smthChanged = true;
                sum1 += cycle[p1];
                sum2 -= cycle[p1];
                p1++;
            }
            if (sum2 < sum3 && p2 + 1 != r) {
                smthChanged = true;
                sum2 += cycle[p2];
                sum3 -= cycle[p2];
                p2++;
            }
        }
    }
    cout << res << endl;
    cout << min(s1, min(s2, s3)) << " " << s1 + s2 + s3 - min(s1, min(s2, s3)) - max(s1, max(s2, s3)) << " " << max(s1, max(s2, s3));
}
