/*IN FISH AT EGOI I TRUST*/
/*IN FISH AT EGOI I TRUST*/
/*IN FISH AT EGOI I TRUST*/
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppl;
typedef long double ld;

mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,popcnt")

int n,a[1000009],b[1000009],k[1000009];
ll c;
unordered_map<ll,int> mp;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++) {
            cin>>a[i];
            b[i]=b[i-1]+a[i];
    }
    c=b[n]/3;
    mp[0]=1;
    for(int i=1;i<n;i++){
        ll o=mp[b[i]-c];
        mp[b[i]]=i+1;
        if(o==0) continue;
        k[i]=o;
        if(k[o-1]!=0) {
            cout<<0<<"\n"<<k[o-1]<<" "<<k[i]<<" "<<i+1<<endl;
            return 0;
        }
    }

    return 0;
}
