#include <bits/stdc++.h>
#define int long long
#define elif else if
#define pb push_back

using namespace std;
vector<vector<int>> adj;
vector<vector<int>> adj2;
set<int> black_list;
const int INF = 1e9 + 7;

vector<pair<pair<int, int>, int>> bb;

//mt19937(43243242434) tss;

long long bfs(int s, int en, set<int> &path){

    int n = adj.size();

    vector<bool> visited(n+1, false);
    vector<int> dist(n+1, INF);
    deque<int> q;
    dist[s] = 0;
    visited[s] = 1;
    q.push_back(s);
    int ans = 0;
    while(!q.empty()){
        int v = q.front();
        q.pop_front();
        if(adj[v].size() == 0) break;
        for(auto u: adj[v]){
            if(visited[u]) break;
            visited[u] = 1;
            dist[u] = dist[v] + 1;
            q.push_back(u);
        }
    }
    int tmp = 0ll;
    for(int i = 0; i < n; i++){
        if(dist[i+1] != INF) tmp += bb[i].second;
    }
    return tmp;
}

void solve(){
    int n; cin >> n;
    vector<int> a(n);
    for(int &x: a) cin >> x;
    int mn = 0;
    int q = 100;
    vector<int> ans = {0, 0, 0};
     a.push_back(a[0]);
    while(q--){
        random_shuffle(begin(a), end(a));
       
        int mn = INF;
        int mx = -INF;
        int a1 = rand() % n;
        int a2 = rand() % n;
        while(a2 == a1) a2 = rand() % n;
        int a3 = rand() % n;
        while(a3 == a1 || a3 == a2) a3 = rand() % n;
        int sm1 = 0;
        int sm2 = 0;
        int sm3 = 0;
        for(int i = 0; i <= n; i++){
            if(i <= a1) sm1 += a[i];
            else if(i <= a2) sm2 += a[i];
            else sm3 += a[i];
        }
        int tmp1 = max(sm1, max(sm3, sm2));
        int tmp2 = min(sm1, min(sm3, sm2));
        if(abs(tmp1 - tmp2) < mn){
            mn = abs(tmp1 - tmp2);
            ans = {a1+1, a2+1, a3+1};
        }
    }
    cout << mn << "\n";
    for(int x: ans) cout << x << " ";
    cout << endl;
}

signed main()
{
    int t = 1; //cin >> t;
    while(t--) solve();
    return 0;
}
