#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 = 1, p2 = 2, p3, res = INT_MAX, s1 = 1, s2 = 2, s3;
    vector<int> cycle;
    bool smthChanged = 1;
    cin >> n;
    p3 = n;
    s3 = n;
    for (i = 0; i < n; i++) {
        cin >> t;
        cycle.push_back(t);
    }
    sum1 = cycle[s1 - 1];
    sum2 = cycle[s2 - 1];
    sum3 = 0;
    for (i = 2; i < n; i++) {
        sum3 += cycle[i];
    }
    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 = p1, s2 = p2, s3 = p3;
        }
        if (sum1 < sum2 && p1 + 1 != p2) {
            smthChanged = true;
            p1++;
            sum1 += cycle[p1 - 1];
            sum2 -= cycle[p1 - 1];
        }
        if (res > max(sum1, max(sum2, sum3)) - min(sum1, min(sum2, sum3))) {
            res = max(sum1, max(sum2, sum3)) - min(sum1, min(sum2, sum3));
            s1 = p1, s2 = p2, s3 = p3;
        }
        if (sum2 < sum3 && p2 + 1 != n + 1) {
            smthChanged = true;
            p2++;
            sum2 += cycle[p2 - 1];
            sum3 -= cycle[p2 - 1];
        }
        if (res > max(sum1, max(sum2, sum3)) - min(sum1, min(sum2, sum3))) {
            res = max(sum1, max(sum2, sum3)) - min(sum1, min(sum2, sum3));
            s1 = p1, s2 = p2, s3 = p3;
        }
        if (sum3 < sum1 && max((p3 + 1) % (n + 1), 1) != p1) {
            smthChanged = true;
            p3 = max((p3 + 1) % (n + 1), 1);
            sum3 += cycle[p3 - 1];
            sum1 -= cycle[p3 - 1];
        }
    }
    cout << res << endl;
    s1 = max((s1 + 1) % (n + 1), 1);
    s2 = max((s2 + 1) % (n + 1), 1);
    s3 = max((s3 + 1) % (n + 1), 1);
    cout << min(s1, min(s2, s3)) << " " << s1 + s2 + s3 - min(s1, min(s2, s3)) - max(s1, max(s2, s3)) << " " << max(s1, max(s2, s3));
}
