#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
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 (binary_search(pref.begin(),pref.end(),pref[i+1]-(pref[n]/3))){
                f=*lower_bound(pref.begin(),pref.end(),pref[i+1]-pref[n]/3);
                g=i+2;
                break;
            } 
        }
    }
    f++;
    int cur=0;
    for (int i=g-1;i<n;i++){
        cur+=a[i];
        if (cur==pref[n]/3){
            h=i+2;
            break;
        }
    }
    cout<<0<<endl;
    cout<<f<<" "<<g<<" "<<h<<endl;

}
