#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define el '\n'
#define ff first
#define ss second
#define pb push_back
#define point pair <ll, ll>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

const ll N = 1e6 + 10;
const ll inf = 1e18 + 10;

ll a[N], pref[N];

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

    ll n;
    cin >> n;

    for (ll i = 0; i < n; i++)
        cin >> a[i];

    ll ans = inf;
    vector <ll> way;

    auto get = [&](ll x, ll y) -> ll {
        x++, y++;
        ll mx = max({pref[x], pref[y] - pref[x], pref[n] - pref[y]});
        ll mn = min({pref[x], pref[y] - pref[x], pref[n] - pref[y]});
        return mx - mn;
    };

    for (ll i = 0; i < n; i++) {
        for (ll j = 1; j <= n; j++)
            pref[j] = pref[j - 1] + a[j - 1];

        ll id = 0;
        for (ll j = 1; j < n - 1; j++) {
            vector <ll> all;
            for (ll k = 0; k < j; k++) {
                all.pb(get(k, j));
                if (ans > get(k, j)) {
                    ans = get(k, j);
                    way = {(k + 1 + i) % n, (j + 1 + i) % n, i};
                    sort(all(way));
                }
            }

            ll pos = min_element(all(all)) - all.begin();
            for (ll j = 1; j <= pos; j++)
                assert(all[j - 1] >= all[j]);
            for (ll j = pos + 1; j < all.size(); j++)
                assert(all[j - 1] <= all[j]);
        }

        for (ll j = 1; j < n; j++)
            swap(a[j], a[j - 1]);
    }

    cout << ans << el;
    for (ll x : way)
        cout << x + 1 << " ";
    cout << el;

    return 0;
}
