#include <iostream>
#include <vector>
#include <algorithm>
#include <bits/stdc++.h>


using namespace std;
int findriz(int a, int b, int c) {
    return max(max(a, b), c) - min(min(a, b),c);
}
int main() {

    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    vector<int> a;
    vector<int> b;
    vector<int> c;
    int ai= 1, bi = n - 1, ci = n;
    for (int i = 0; i < n - 2; i++) {
        a.push_back(v[i]);
    }
    b.push_back(v[n - 2]);
    c.push_back(v[n - 1]);
    bool check = true;
    int sum1 = 0, sum2 = 0, sum3 = 0;
    for (int i = 0; i < n - 2; i++) {
        sum1 += a[i];
    }
    sum2 = b[0];
    sum3 = c[0];
    int sum = (sum1 + sum2 + sum3)/3;
    while (check && a.size() > 1) {
        if (sum3 + v[ai-1] <= sum) {
            sum1 -= v[ai-1];
            sum3 += v[ai-1];
            ai++;
        }
        else if ( sum2 + v[bi-2] <= sum) {

            sum1 -= v[bi-2];
            sum2 += v[bi-2];

            bi--;
        }
        else if ( sum3 + v[ci-2] <= sum) {
            
            sum2 -= v[ci-2];
            sum3 += v[ci-2];

            ci--;
        }
        else if ( sum2 + v[ci-1] <= sum) {
            
            sum3 -= v[ci-1];
            sum2 += v[ci-1];

            ci++;
        }
        else check = false;
    }
    cout << findriz (sum1, sum2, sum3) << endl;
    cout << ai << " " << bi << " " << ci << endl;

}
