#include <iostream>
#include <vector>
#include <algorithm>
#include <limits>

using namespace std;
using ll = long long;

const ll inf = numeric_limits<ll>::max() / 2;

int main() {
#ifndef DEBUG
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif

    int n;
    cin >> n;

    vector<ll> arr(n);

    for (auto& it : arr) {
        cin >> it;
    }

    vector<ll> pref_sums(n + 1);
    pref_sums[0] = 0;

    for (int i = 0; i < n; i++) {
        pref_sums[i + 1] = pref_sums[i] + arr[i];
    }

    auto get_sum = [&](int l, int r) {
        l = l % n;
        r = r % n;

        if (r < l) {
            return pref_sums[n] - (pref_sums[l] - pref_sums[r]);
        }

        return pref_sums[r] - pref_sums[l];
    };

    auto get_diff = [&](ll a, ll b, ll c) {
        return max({ a, b, c }) - min({ a, b, c });
    };

    ll res = inf;
    int best_i = 0;
    int best_j = 0;
    int best_k = 0;

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < i + n - 1; j++) {
            int low_k = j + 1;
            int high_k = i + n;
            ll sum1 = get_sum(i, j);

            while (high_k - low_k > 1) {
                int middle = (low_k + high_k) / 2;

                ll sum2 = get_sum(j, middle);

                if (sum2 > sum1) {
                    high_k = middle;
                } else {
                    low_k = middle;
                }
            }

            ll curr = get_diff(
                sum1,
                get_sum(j, low_k),
                get_sum(low_k, i)
            );

            if (curr < res) {
                res = curr;
                best_i = i;
                best_j = j;
                best_k = low_k;
            }

            if (low_k + 1 < i + n) {
                ll curr = get_diff(
                    sum1,
                    get_sum(j, low_k + 1),
                    get_sum(low_k + 1, i)
                );
    
                if (curr < res) {
                    res = curr;
                    best_i = i;
                    best_j = j;
                    best_k = low_k + 1;
                }
            }
        }
    }

    cout << res << "\n";

    vector<int> bounds = { best_i % n, best_j % n, best_k % n };
    sort(bounds.begin(), bounds.end());

    for (int bound : bounds) {
        cout << bound + 1 << " ";
    }

    cout << "\n";

    return 0;
}
