#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];
    while (check && a.size() > 1) {
        if (findriz (sum1, sum2, sum3) >= findriz (sum1 - a[0], sum2, sum3 + a[0]) && max(max(sum1, sum2), sum3) == sum1 && min(min(sum1, sum2), sum3) == sum3) {
            c.push_back(a[0]);
            sum1 -= a[0];
            sum3 += a[0];
            a.erase(a.begin());
            ai++;
        }
        else if (findriz (sum1, sum2, sum3) >= findriz (sum1 - a[a.size()-1], sum2 + a[a.size()-1], sum3)  && max(max(sum1, sum2), sum3) == sum1 && min(min(sum1, sum2), sum2) == sum2) {
            b.insert(b.begin(), a[a.size()-1]);
            sum1 -= a[a.size()-1];
            sum2 += a[a.size()-1];
            a.erase(a.end());
            bi--;
        }
        else if(findriz (sum1, sum2, sum3) >= findriz (sum1, sum2 - b[b.size()-1], sum3 + b[b.size()-1]) && max(max(sum1, sum2), sum3) == sum2 && min(min(sum1, sum2), sum2) == sum3) {
            c.insert(c.begin(), b[b.size()-1]);
            sum2 -= b[b.size()-1];
            sum3 += b[b.size()-1];
            b.erase(b.end());
            ci--;
        }

        else if(findriz (sum1, sum2, sum3) >= findriz (sum1, sum2 + c[0], sum3 - c[0]) && max(max(sum1, sum2), sum3) == sum3 && min(min(sum1, sum2), sum2) == sum2) {
            b.insert(b.end(), c[0]);
            sum2 += c[0];
            sum3 -= c[0];
            c.erase(c.begin());
            ci++;
        }
        else check = false;
    }
    cout << findriz (sum1, sum2, sum3) << endl;
    cout << ai << " " << bi << " " << ci << endl;

}
