#include <bits/stdc++.h>
using namespace std;

int main() {
    int n;
    cin>>n;
    vector<int> a(n);
    vector<int> pref(n);
    for (int i=0;i<n;i++){
        cin>>a[i];
        pref[i+1]=pref[i]+a[i];
    }
    int f,g,h;
    for (int i=0;i<n;i++){
        if (pref[i+1]>=pref[n]/3){
            if (lower_bound(pref.begin(),pref.begin()+i+1,pref[i+1]-(pref[n]/3))!=pref.end()){
                f=*lower_bound(pref.begin(),pref.begin()+i+1,pref[i+1]-pref[n]/3)+1;
                g=i+2;
                break;
            }
            
        }
    }
    int cur=0;
    for (int i=g-1;i<n;i++){
        cur+=a[i];
        if (cur==pref[n]/3){
            h=i+2;
            break;
        }
    }
    if (cur==pref[n]/3){
        cout<<0<<endl;
        cout<<f<<" "<<g<<" "<<h<<endl;
    }else{
        int cur=0;
        for (int i=g-2;i>-1;i--){
            cur+=a[i];
            if (cur==pref[n]/3){
                h=i+2;
                break;
            }
        }
        cout<<0<<endl;
        cout<<h<<" "<<f<<" "<<g<<endl;
    }
}
