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

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n; cin>>n; int a[n+1]; for (int i=1; i<=n; i++) cin>>a[i];

    long long s=0;
    for (int i=1; i<=n; i++) s+=a[i];
    long long s1 = s/3;
    long long pref[n+1]; pref[0]=0;
    for (int i=1; i<=n; i++) pref[i] = pref[i-1]+a[i];

int ans1, ans2, ans3;
    for (int i=1; i<=n; i++) {
        if (pref[i]-s1<0) continue;
        int x = lower_bound(pref, pref+n, pref[i]-s1) - pref;
        if (pref[i]-pref[x]==s1) {
            ans2=i; ans1=x;
            break;
        }
    }
    for (int i=ans2+1; i<=n; i++) if (pref[i]-pref[ans2]==s1) ans3=i;
    cout<<0<<"\n";
    cout<<ans1+1<<' '<<ans2+1<<' '<<ans3+1;
    
}
