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

#define int long long
#define len(v) (int) (v.size())
#define all(v) v.begin(), v.end()
#define rall(v) rbegin(v), rend(v)

istream& operator>>(istream& is, vector<int>& v) {
    for (int i = 0; i < len(v); i++) {
        is >> v[i];
    }
    return is;
}

ostream& operator<<(ostream& os, vector<int>& v) {
    for (int i = 0; i < len(v); i++) {
        os << v[i] << ' ';
    }
    return os;
}

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    cin >> a;
    vector<int> p(2 * n + 1);
    for (int i = 0; i < 2 * n; i++) {
        p[i + 1] = p[i] + a[i % n];
    }

    int sm = accumulate(all(a), 0ll);
    int ans = 1e18, x, y, z;

    auto check = [&] (int mn_l, int mn_r) {
        int l = mn_r, r = n + mn_l;
        while (l + 1 < r) {
            int m = (l + r) / 2;
            int left = p[m] - p[mn_r], right = p[n + mn_l] - p[m];
            if (right >= left) {
                l = m;
            }
            else {
                r = m;
            }
        }
        int mx = min(p[l + 1] - p[mn_r], p[n + mn_l] - p[l]);
        int mn = p[mn_r] - p[mn_l];
        int md = sm - mx - mn;
        if (md < mn || mx < mn) return false;

        int res = mx - mn;
        if (res < ans) {
            if (mx == p[l + 1] - p[mn_r]) l++;
            ans = res;
            if (mn_r >= n) {
                x = mn_r - n;
                y = l - n;
                z = mn_l;
            }
            else if (l >= n) {
                x = l - n;
                y = mn_l;
                z = mn_r;
            }
            else {
                x = mn_l;
                y = mn_r;
                z = l;
            }
        }
        return true;
    };

    for (int mn_l = 0; mn_l < n; mn_l++) {
        int l = mn_l + 1, r = n + mn_l;
        while (l + 1 < r) {
            int m = (l + r) / 2;
            if (check(mn_l, m)) {
                l = m;
            }
            else {
                r = m;
            }
        }
        check(mn_l, l);
    }

    cout << ans << '\n';
    cout << x + 1 << ' ' << y + 1 << ' ' << z + 1 << '\n';
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}