#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];
    map<long long, long long> mp;
    for (int i=0; i<=n; i++) mp[pref[i]]=i;

    int ans1, ans2, ans3;
    for (int i=1; i<=n; i++) {
        if (!mp[pref[i]-s1]) continue;
        if (!mp[pref[i]+s1]) continue;
        ans1 = mp[pref[i]-s1];
        ans2 = i;
        ans3 = mp[pref[i]+s1];
    }
    //for (int i=ans2+1; i<=n; i++) if (pref[i]-pref[ans2]==s1) ans3=i;
    cout<<0<<"\n";
    if (s==0) cout<<"1 2 3";
    else {
        if (ans3==n) cout<<1<<' '<<ans1+1<<' '<<ans2+1;
        else cout<<ans1+1<<' '<<ans2+1<<' '<<ans3+1;
    }
    
}