#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 = 100000000000000;

mt19937 rnd_(12);



vector <vector <pair <int , int>>> g;
vector <int> sum;

vector <int> pref;
int get(int l , int r) {
    if (l > r)
        return 0;

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

pair <int , int> dv(int  l , int r) {
    int lx = l - 1;
    int rx = r;

    while (rx - lx > 1) {

        int mid = (lx+ rx) / 2;

        if (get(l , mid) < get(mid+1 , r)) {
            lx = mid;
        }
        else
            rx = mid;
    }

    pair <int , int> p1;
    int x1 = get(l , lx);
    int x2 = get(lx+1 , r);

    p1.first = min(x1 , x2);
    p1.second = lx+1;

    pair <int , int> p2;

    x1 = get(l , lx+1);
    x2 = get(lx+2 , r);

    p2.first = min(x1 , x2);
    p2.second = lx+2;

    if (lx == -1)
        return p2;


    if (lx+1 == r)
        return p1;

    if (p1.first > p2.first)
        return p1;
    else
        return p2;
}



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


    int times = 1;

    while (times--) {

        int n;
        cin >> n;


        vector <int> a (n);

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

        if (n == 3) {
            sort(a.begin() , a.end());

            cout << a[2] - a[0] << "\n";

            cout << 1 << " " << 2 << " " << 3 << "\n";
            continue;
        }

        vector <int> b(2*n);

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

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


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

        int y = 2;

        int sz = n - 2;

        int ind = 0;

            for (int k = 0 ; k < n+5 ; k++) {

                int i = ind;

                int lx_ = 0;
                int rx_ = n - 2;

                while (sz > 1) {
                    int sz_ = sz-1;

                    int lx = i + sz_;
                    int rx = i+ n -  1;

                    pair <int , int> p = dv(lx , rx);

                    int s1 = get(i , i+sz_ - 1);
                    int s2 = p.first;
                    int s3 = get(0 , n- 1) - s1 - s2;

                    bool f = false;
                    if (s1 >= s3) {
                        if (ans > s1 - s2)
                        {
                            ans= s1 - s2;
                            r1 = i;
                            r2 = i+ sz_;
                            r3 = p.second;
                        }
                        f = true;
                    }

                    if (f == true)
                        sz--;
                    else
                        break;
                }

                sz++;

                ind += n -1;
                ind %= n;
            }

        cout << ans << "\n";

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

        vector <int> v;

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

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

        cout << v[0] + 1 <<" " << v[1] +1 << " " << v[2] +1 << "\n";
    }
}