#include <bits/stdc++.h>

using namespace std;

#define print(a) cerr << "[" << #a << " = " << a << "] "
#define dbg(a) print(a) << "\n"
#define dbg2(a, b) print(a); print(b) << "\n"
#define dbg3(a, b, c) print(a); print(b); print(c) << "\n"

#define int long long
#define ll long long
#define pi pair<int, int>
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sz(a) ((int)(a).size())
#define divup(a, b) (((a) + (b) - 1) / (b))

template <class T> bool chmax(T&a, const T&b) {return b > a ? a = b, 1 : 0;};
template <class T> bool chmin(T&a, const T&b) {return b < a ? a = b, 1 : 0;};

const int mod = 1e9 + 7;
const int inf = (int)(1e18) + 7;

const int maxn = 2e5 + 7;
const int N = 1e4 + 7;
const int logn = 20;

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

    int ans = inf;
    vector <int> res;
    for (int i = 0; i < n; ++i) {
        vector <int> b; 
        for (int j = i; j < n; ++j) {
            b.push_back(a[j]);
        }
        for (int j = 0; j < i; ++j) {
            b.push_back(a[j]);
        }
        // dbg(i);
        // for (auto x : b) {
        //     dbg(x);
        // }
        vector <int> best(n, -1), mn_sum(n, 0), mx_sum(n, 0);
        deque <int> c;
        int sum1 = b[n - 2], sum2 = b[n - 1];
        mn_sum[n - 2] = min(sum1, sum2);
        mx_sum[n - 2] = max(sum1, sum2);
        best[n - 2] = n - 2;
        c.push_back(n - 2);
        for (int i = n - 3; i >= 0; --i) {
            sum1 += b[i];
            c.push_back(i);
            while (sz(c) > 1) {
                int j = c.front();
                int cur = max(sum1, sum2);
                int nxt = max(sum1 - b[j], sum2 + b[j]);
                if (nxt < cur) {
                    sum1 -= b[j];
                    sum2 += b[j];
                    c.pop_front();
                } else break;
            }
            best[i] = c.front();
            mn_sum[i] = min(sum1, sum2);
            mx_sum[i] = max(sum1, sum2);
        }
        // for (int i = 0; i < n; ++i) {
        //     dbg3(i, mn_sum[i], mx_sum[i]);
        // }
        int cur_sum = 0, cur = inf;
        vector <int> t;
        for (int i = 0; i + 2 < n; ++i) {
            cur_sum += b[i];
            int mx = cur_sum, mn = cur_sum;
            chmax(mx, mx_sum[i + 1]);
            chmin(mn, mn_sum[i + 1]);
            // dbg3(i, mn, mx);
            // dbg(cur_sum);
            if (mx - mn < cur) {
                cur = mx - mn;
                t.clear();
                t = {0, i + 1, best[i + 1] + 1};
            }
            // dbg(cur);
        }
        if (cur < ans) {
            ans = cur;
            res.clear();
            for (auto j : t) {
                res.push_back((j + i) % n + 1);
            }
        }
    }
    sort(all(res));
    cout << ans << "\n";
    for (auto i : res) cout << i << " ";
}

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

    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);

    solve();
} 