#include <bits/stdc++.h>
using namespace std;
#define int int64_t
signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin>>n;
    vector<int> a(n);
    for(auto& u:a){
        cin>>u;
    }
    int mini=INT_MAX;
    vector<int> pref(n+1,0);
    for(int i=1;i<=n;i++){
        pref[i]=pref[i-1]+a[i-1];
    }
    int t1,t2,t3;
    // for(auto u:pref){cout<<u<<" ";}
    // cout<<endl;
    int flag = 1;
    int sum = pref[n]/3;
    // cout<<sum<<endl;
    for(int i=1;i<=n-2;i++){
        for(int j=i+1;j<=n-1;j++){
            int ts = pref[j-1]-pref[i-1];
            if(ts>sum){break;}
            if(ts==sum){
                for(int k=j+1;k<=n;k++){
                    if(pref[k-1]-pref[j-1]==sum){
                        cout<<"0\n"<<i<<" "<<j<<" "<<k;
                        return 0;
                    }
                }
            }
        }
    }
    cout<<mini<<endl<<t1<<" "<<t2<<" "<<t3;
}
