#include <bits/stdc++.h>
using namespace std;

const int DIM = 1e6;
int arr[DIM], len;
long long pref[DIM];
int compressed[DIM];

void input(){
    int q_num; cin >> q_num;
    len = 0;
    for (int i = 0, a_i; i < q_num; ++i){
        cin >> a_i;
        if (a_i != 0){
            arr[len] = a_i;
            compressed[len] = i+1;
            ++len;
        }
    }
}
void output(){
    for (int i = 0; i < len; ++i)
        cout << arr[i] << ' ';
    cout << '\n';
    for (int i = 0; i < len; ++i)
        cout << compressed[i] << ' ';
    cout << '\n';
    for (int i = 0; i < len; ++i)
        cout << pref[i] << ' ';
    cout << '\n';
}

void calc_pref(){
    pref[0] = arr[0];
    for (int i = 1; i < len; ++i)
        pref[i] = pref[i-1] + arr[i];
}
long long sum_segm(int start, int end){
    if (start > end)
        return pref[end-1] + pref[len-1] - pref[start-1];
    return pref[end-1] - pref[start-1];
}

long long calc_diff(int x, int y, int z){
    return max(sum_segm(x, y), max(sum_segm(y, z), sum_segm(z, x))) - min(sum_segm(x, y), min(sum_segm(y, z), sum_segm(z, x)));
}


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    input();
    calc_pref();

    long long min_diff = 1e18, min_x, min_y, min_z;
    for (int x = 0; x < len-2; ++x)
        for (int y = x + 1; y < len-1; ++y)
            for (int z = y + 1; z < len; ++z)
                if (calc_diff(x, y, z) < min_diff){
                    min_diff = calc_diff(x, y, z);
                    min_x = x;
                    min_y = y;
                    min_z = z;
                }

    cout << calc_diff(min_x, min_y, min_z) << '\n';
    cout << compressed[min_x] << ' ' << compressed[min_y] << ' ' << compressed[min_z] << '\n';

    //output();

    return 0;
}
