#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>

using namespace std;

#define int long long

int inf = 1000000000;

mt19937 rnd_(12);


vector <int> pref;

int get(int l , int r) {
    if (l == 0)
        return pref[r];
    else
        return pref[r] - pref[l - 1];
}


signed main() {
    int n;
    cin >> n;

    vector <int> a (n);

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

    vector <int> b;


    for (int i = 0 ; i <n ; i++) {
        b.push_back(a[i]);
    }


    for (int i = 0 ; i <n ; i++) {
        b.push_back(a[i]);
    }

    pref.resize(2*n);

    int p = 0;

    for (int i = 0 ; i < 2*n ; i++) {
        p += b[i];

        pref[i] = p;

        cout << pref[i] << " ";
    }
    cout << endl;

    int ans = inf;

    int r1 = -1;
    int r2 = -1;
    int r3 = -1;

    for (int l = 0 ; l < n ; l++) {
        for (int sz = 1 ; sz < n - 2 ; sz++) {
            int r = l +sz;

            int lx = r;
            int rx = l + n - 1;

            int s=  get(lx , rx);

            s/=2;

            int s_= get(0 , lx - 1);

            int ind = lower_bound(pref.begin() , pref.end() , s_ + s ) - pref.begin();

            int s2 = get(l , l+sz - 1);
            int x = get(lx , ind);
            int y = pref[n- 1] - s2 - x;

            if ((x <= s2) and (y<= s2))
            {
                if (ans > s2 - min(x , y)) {
                    ans= min(ans , s2 - min(x , y));
                    r1 = l;
                    r2 = lx;
                    r3 = ind+1;


                }
            }
        }
    }


    r1 %= n;
    r2 %= n;
    r3 %= n;

    cout << ans << "\n";


    vector <int> v;

    v.push_back(r1);
    v.push_back(r2);
    v.push_back(r3);

    sort(v.begin() , v.end());

    for (int i = 0 ; i < v.size() ; i++) {
        cout << v[i]+1 << " ";
    }
}
