#include <bits/stdc++.h>
using namespace std;
int mas[3000000];
int psum[3000000];
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    int sum=0;
    for (int i=0;i<n;i++) {
        cin>>mas[i];
        sum+=mas[i];
    }
    int goal=sum/3;
    int s=0;
    int k=0;
    int i=0;
    for (;i<n;i++) {

        s+=mas[i];
        if (s==goal) {break;}
        if (s>goal) {
            s-=mas[k];k++;
            if (s==goal) {break;}
        }
    }
    goal=sum-goal;
    goal/=2;
    int j=i+1;
    s=0;
    for (;j<n;j++) {
        s+=mas[j];
        if (s>=goal) {break;}
    }
    cout<<s-(sum-sum/3-s)<<'\n';
    cout<<k+1<<' '<<i+2<<' '<<j+3;
}
