#include <bits/stdc++.h>
using namespace std;
long long getSum(vector<long long> prefix, int l, int r){
    r = r % prefix.size();
    l = l % prefix.size();
    if(l <= r){
        return (prefix[r] - (l > 0 ? prefix[l - 1] : 0));
    }
    else{
        return (prefix[prefix.size() - 1] - (l > 0 ? prefix[l - 1] : 0) + prefix[r]);
    }
}
long long max(long long a, long long b, long long c){
    return max(a, max(b, c));
}
long long min(long long a, long long b, long long c){
    return min(a, min(b, c));
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin>>n;
    vector<int> a(n);
    vector<long long> s(n);
    for(int i = 0;i < n;i++){
        cin >> a[i];
        s[i] = a[i] + (i > 0 ? s[i - 1] : 0);
    }
    long long sum = s[n - 1];
    long long sum3 = sum / 3;
    /*for(int i = 0;i < n;i++){
        cout << s[i] << " ";
    }*/
    if(n == 3){
        cout << (max(a[0], max(a[1], a[2])) - min(a[0], min(a[1], a[2]))) << endl;
        cout << 1 << " " << 2 << " " << 3;
        return 0;
    }
    int I1 = 0;
    int I2 = -1;
    int I3 = -1;
    int max1I = 0;
    int max2I = -1;
    int max3I = -1;
    for(int i = 1;i < n;i++){
        if(s[i] > sum3&&I2 == -1){
            if(abs(s[i - 1] - sum3) > abs(s[i] - sum3)){
                I2 = i + 1;
                max2I = i + 1;
            }
            else{
                I2 = i;
                max2I = i;
            }
        }
        if(I2 != i&&s[i] > sum3 * 2&&I3 == -1){
            if(abs(s[i - 1] - sum3 * 2) > abs(s[i] - sum3 * 2)){
                I3 = i + 1;
                max3I = i + 1;
            }
            else{
                I3 = i;
                max3I = i;
            }
        }
    }
    int diff = max(getSum(s, I3, I1 - 1), getSum(s, I1, I2 - 1), getSum(s, I2, I3 - 1)) - min(getSum(s, I3, I1 - 1), getSum(s, I1, I2 - 1), getSum(s, I2, I3 - 1));
    for(int i = 1;i < n;i++){
        I1 = i;
        while(getSum(s, I1, I2 - 1) < sum3){
            I2 ++;
        }
        if(abs(getSum(s, I1, I2 - 1) - sum3) > abs(getSum(s, I1, I2 - 2) - sum3)){
            I2--;
        }
        while(getSum(s, I2, I3 - 1) < sum3){
            I3 ++;
        }
        if(abs(getSum(s, I2, I3 - 1) - sum3) > abs(getSum(s, I2, I3 - 2) - sum3)){
            I3--;
        }
        if(I3 % n == I1){
            I3 --;
        }
        if(
            max(getSum(s, I3, I1 - 1), getSum(s, I1, I2 - 1), getSum(s, I2, I3 - 1)) - 
            min(getSum(s, I3, I1 - 1), getSum(s, I1, I2 - 1), getSum(s, I2, I3 - 1))
            <
            diff
        ){
            max1I = I1;
            max2I = I2;
            max3I = I3;
            diff = max(getSum(s, I3, I1 - 1), getSum(s, I1, I2 - 1), getSum(s, I2, I3 - 1)) - 
            min(getSum(s, I3, I1 - 1), getSum(s, I1, I2 - 1), getSum(s, I2, I3 - 1));
        }
    }
    cout << diff << endl;
    cout << max1I + 1 << " " << max2I + 1 << " " << max3I + 1;
}
