#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll long long
#define vll vector<ll>
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
#define fr first
#define se second
#define pb push_back
#define vvll vector<vll>
#define pll pair<ll, ll>
#define vbool vector<bool>
#define INF 10000000000000000

using namespace std;
using namespace __gnu_pbds;

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

    ll n;
    cin >> n;
    vll a(n), pref(n+7, 0);
    ll sum = 0;
    for (int i = 0; i < n; i ++) {
        cin >> a[i];
        pref[i+1] = pref[i];
        pref[i+1] += a[i];
        sum += a[i];
    }
    /*if (n == 3) {
        sort(a.begin(), a.end());
        cout << a[2]-a[0] << endl << 1 << ' ' << 2 << ' ' << 3 << endl;
        return 0;
    }*/
    ll minl = INF;
    ll x1 = -1, y, z;

    for (int i = 0; i < n; i ++) {
        ll x = i+1;
        for (int j = i; j < n-1; j ++) {
            while (x < n) {
                if (x <= j || pref[x+1]-pref[j+1] < pref[j+1]-pref[i]) {
                    x ++;
                }
                else break;

            }
            if (x == n) x --;
            if (x == j) break;
            //cout << i << ' ' << j << ' ' << x << endl;
            ll s = pref[x+1]-pref[j+1], s1 = pref[x]-pref[j+1];
            ll s2 = pref[j+1]-pref[i];
            //cout << s << ' ' << s1 << ' ' << s2 << endl;
            if (max({s, s2, sum-(s+s2)})-min({s, s2, sum-(s+s2)}) < minl) {
                minl = max({s, s2, sum-(s+s2)})-min({s, s2, sum-(s+s2)});
                x1 = i+1;
                y = j+2;
                z = x+2;
            }
            if (x-1 > j && max({s1, s2, sum-(s1+s2)})-min({s1, s2, sum-(s1+s2)}) < minl) {
                minl = max({s1, s2, sum-(s1+s2)})-min({s1, s2, sum-(s1+s2)});
                x1 = i+1;
                y = j+2;
                z = x+1;
            }
        }
    }
    //if(x1 == -1) while(1);
    sort(b.begin(), b.end());
        if(b[0] != 1 || b[1] != 2 || b[2] != 3) while(1);
    
    cout << minl << endl;
        vll b({x1, y, z});
        
        for (int i : b) cout << i << ' ';
}