#include <bits/stdc++.h>

using namespace std;
using ll = long long;

vector<ll> prefix;
ll answer, size1, size2, size3 , change = 0;

ll func(ll size) {
    ll pos = 0, l = 0, r = prefix.size() - 1, min1, max1, ans;
    while (l < r) {
        ll mid = (l + r) / 2;
        if (prefix[mid] > size) {
            r = mid - 1;
        }else if (prefix[mid] < size) {
            l = mid + 1;
        }else {
            l = mid;
            break;
        }
    }
    if (l > r) {
        return 1000000000;
    }
    pos = l;
    min1 = prefix[pos];
    max1 = prefix[pos];
    l = pos + 1, r = prefix.size() - 1;
    while (l < r) {
        ll mid = (l + r) / 2;
        if (prefix[mid] - prefix[pos] > size) {
            r = mid - 1;
        }else if (prefix[mid] - prefix[pos] < size) {
            l = mid + 1;
        }else {
            l = mid;
            break;
        }
    }
    if (l > r) {
        return 1000000000;
    }
    if (min1 > prefix[l] - prefix[pos]) {
        min1 = prefix[l] - prefix[pos];
    }
    if (max1 < prefix[l] - prefix[pos]) {
        max1 = prefix[l] - prefix[pos];
    }
    if (min1 > prefix[prefix.size() - 1] - prefix[l]) {
        min1 = prefix[prefix.size() - 1] - prefix[l];
    }
    if (max1 < prefix[prefix.size() - 1] - prefix[l]) {
        max1 = prefix[prefix.size() - 1] - prefix[l];
    }
    ans = max1 - min1;
    if (ans < answer) {
        answer = ans;
        size1 = change + 1;
        size2 = pos + change + 2;
        size3 = l + change + 2;
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);
    ll n, sum = 0;
    cin >> n;
    vector<ll> a(n);
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    answer = sum + 1000;
    for (ll stpos = 0; stpos < n; stpos++) {
        ll l = 0, r = sum, mid1, mid2;
        prefix.resize(n);
        prefix[0] = a[0];
        for (ll i = 1; i < n; i++) {
            prefix[i] = prefix[i - 1] + a[i];
        }
        while (l < r) {
            mid1 = l + (l + r) / 3;
            mid2 = r - (l + r) / 3;
            if (func(mid1) > func(mid2)) {
                r = mid2 - 1;
            }else if (func(mid1) < func(mid2)) {
                l = mid1 + 1;
            }else {
                break;
            }
        }
        ll ab;
        ab = a[0];
        a.erase(a.begin());
        a.push_back(ab);
        change++;
    }
    cout << answer << '\n';
    cout << size1 << ' ' << size2 << ' ' << size3 << '\n';
}
