#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;
    for(int i=1;i<=n-2;i++){
        for(int j=i+1;j<=n-1;j++){
            if(pref[j-1]-pref[i-1]==pref[n]/3){
                int k=pref[j-1]-pref[i-1];
                for(int h=j+1;h<=n;h++){
                    if(pref[n]/3==pref[h-1]-pref[j-1]){
                        mini=0;
                        t1=i;t2=j;t3=h;

                    }
                }
            }
        }

    }
    cout<<mini<<endl<<t1<<" "<<t2<<" "<<t3;
}
