#pragma GCC optimize("O3")
#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, way[3];

    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];

        for (ll j = 0; j < n - 2; j++) {
            ll l = j, r = n - 1, want = (pref[n] - pref[j + 1]) / 2;
            while (l + 1 < r) {
                ll mid = (l + r) >> 1;

                if (pref[mid + 1] - pref[j + 1] <= want) l = mid;
                else r = mid;
            }

            if (l != j && pref[j + 1] >= max(pref[l + 1] - pref[j + 1], pref[n] - pref[l + 1])) {
                if (ans > get(j, l)) {
                    ans = get(j, l);
                    way[0] = (l + 1 + i) % n, way[1] = (j + 1 + i) % n, way[2] = i;
                }
            }
            if (pref[j + 1] >= max(pref[r + 1] - pref[j + 1], pref[n] - pref[r + 1])) {
                if (ans > get(j, r)) {
                    ans = get(j, r);
                    way[0] = (r + 1 + i) % n, way[1] = (j + 1 + i) % n, way[2] = i;
                }
            }
        }

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

    cout << ans << el;
    sort(way, way + 3);
    for (ll i = 0; i < 3; i++)
        cout << way[i] + 1 << " ";
    cout << el;

    return 0;
}