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

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

struct Division{
    int x, y, z;
};

void input(){
    int q_num; cin >> q_num;
    len = 3;
    cin >> arr[0] >> arr[1] >> arr[2];
    compressed[0] = 1; compressed[1] = 2; compressed[2] = 3;
    for (int i = 0, a_i; i < q_num-3; ++i){
        cin >> a_i;
        if (a_i != 0){
            arr[len] = a_i;
            compressed[len] = i+4;
            ++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 find_Z(int x, int y){
    int left = y + 1, right = len-1, t_l, t_r;

    while (left < right){
        t_l = (left * 2 + right) / 3;
        t_r = (left + 2 * right + 2) / 3;
        
        if (calc_diff(x, y, t_l) <= calc_diff(x, y, t_r))
            right = t_r - 1;
        else
            left = t_l + 1;
    }
    return left;
}

pair<int, int> find_YZ(int x){
    int left = x + 1, right = len-2, t_l, t_r;

    while (left < right){
        t_l = (left * 2 + right) / 3;
        t_r = (left + 2 * right + 2) / 3;

        if (calc_diff(x, t_l, find_Z(x, t_l)) <= calc_diff(x, t_r, find_Z(x, t_r)))
            right = t_r - 1;
        else
            left = t_l + 1;
    }

    return {left, find_Z(x, left)};
}

Division find_XYZ(){
    int left = 0, right = len-3, t_l, t_r;

    while (left < right){
        t_l = (left * 2 + right) / 3;
        t_r = (left + 2 * right + 2) / 3;

        pair<int,int> left_YZ = find_YZ(t_l), right_YZ = find_YZ(t_r);
        if (calc_diff(t_l, left_YZ.first, left_YZ.second) <= calc_diff(t_r, right_YZ.first, right_YZ.second))
            right = t_r - 1;
        else
            left = t_l + 1;
    }

    pair<int, int> res_YZ = find_YZ(left);
    return {left, res_YZ.first, res_YZ.second};
}

pair<int,int> find_place(){
    int left = 0, right = len-3, t_l, t_r;

    while (left < right - 50000){
        t_l = (left * 2 + right) / 3;
        t_r = (left + 2 * right + 2) / 3;

        pair<int,int> left_YZ = find_YZ(t_l), right_YZ = find_YZ(t_r);
        if (calc_diff(t_l, left_YZ.first, left_YZ.second) <= calc_diff(t_r, right_YZ.first, right_YZ.second))
            right = t_r - 1;
        else
            left = t_l + 1;
    }

    return {left, right};
}

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

    input();
    calc_pref();

    pair<int,int> diapason = find_place();
    long long min_diff = calc_diff(0,1,2), min_x = 0, min_y = 1, min_z = 2;
    for (int x = diapason.first; x < diapason.second; ++x){
        pair<int,int> YZ = find_YZ(x);
        //cout << compressed[x] << ' ' << compressed[YZ.first] << ' ' << compressed[YZ.second] << ' ' << calc_diff(x, YZ.first, YZ.second) << '\n';
        if (min_diff > calc_diff(x, YZ.first, YZ.second)){
            min_diff = calc_diff(x, YZ.first, YZ.second);
            min_x = x;
            min_y = YZ.first;
            min_z = YZ.second;
        }
    }

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

/*
    Division min_XYZ = find_XYZ();

    cout << calc_diff(min_XYZ.x, min_XYZ.y, min_XYZ.z) << '\n';
    cout << compressed[min_XYZ.x] << ' ' << compressed[min_XYZ.y] << ' ' << compressed[min_XYZ.z] << '\n';
*/

    return 0;
}
