#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
using namespace std;
struct node{ll first, second, third;};
void solve(){
    ll n;
    cin >> n;
    vector<ll> values;
    vector<ll> positions;
    ll whole = 0;
    for(ll i = 0; i<n; i++){
        ll value;
        cin >> value;
        positions.push_back(i+1);
        values.push_back(value);
        whole+=value;
    }
    for(ll i = 0; i<n-1; i++){ values.push_back(values[i]); positions.push_back(i+1);}
    ll answer = 1e18;
    node ans;
    ans.first=1e18;
    ans.second=1e18;
    ans.third=1e18;
    for(ll i = 0; i<=n; i++){
        ll first = 0;
        for(ll j = i+1; j<=i+n-2; j++){
            first+=values[j-1];
            ll second = 0;
            for(ll k = j+1; k<=i+n-1; k++){
                second+=values[k-1];
                ll third = whole-first-second;
                ll maximum = max(first, max(second, third));
                ll minimum = min(first, min(second, third));
                if(answer>maximum-minimum){
                    answer=maximum-minimum;
                    ans.first=positions[i];
                    ans.second=positions[j];
                    ans.third=positions[k];
                }
            }
        }
    }
    if(ans.first>ans.second) swap(ans.first, ans.second);
    if(ans.second>ans.third) swap(ans.second, ans.third);
    if(ans.first>ans.second) swap(ans.first, ans.second);
    cout << answer << '\n';
    cout << ans.first << ' ' << ans.second << ' ' << ans.third << '\n';
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    freopen("input.txt", "r", stdin);
    ll tests;
    tests=1;
    while(tests--) solve();
}