#include <bits/stdc++.h>

using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    ll n;cin >> n;
    ll a[n+1];
    ll sall=0;
    for(ll i=1; i<=n; i++) {cin >> a[i];sall+=a[i];}
    ll p[n+1];
    ll ans=1000000000000000000;
    ll ansx, ansy,ansz;
    p[0]=0;
    for(ll i=1; i<=n; i++)
    {
        p[i]=p[i-1]+a[i];
    }
    for(ll x=1; x<=n-2; x++)
    {
        ll xe=x;
        while(p[xe]-p[x-1]<sall/3)xe++;
        if(p[xe]-p[x-1]>sall/3)continue;
        ll y=xe+1;
        ll ye=y;
        while(p[ye]-p[y-1]<sall/3)ye++;
        if(p[ye]-p[y-1]>sall/3)continue;
        ll z=ye+1;
        cout << '0' << endl << x << ' ' << y << ' ' << z;
        return 0;
    }
    //cout << ans << endl << ansx << ' ' << ansy << ' ' << ansz;
}
