#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];
    }
    ll xe=0, ye=0;
    for(ll x=1; x<=n-2; x++)
    {
        if(xe==0)xe=x;
        while(p[xe]-p[x-1]<sall/3)xe++;
        if(p[xe]-p[x-1]>sall/3)continue;
        if(ye==0)ye=xe+1;
        while(p[ye]-p[xe]<sall/3)ye++;
        if(p[ye]-p[xe]>sall/3)continue;
        ll z=ye+1;
        cout << '0' << endl << x << ' ' << xe+1 << ' ' << z;
        return 0;
    }
    //cout << ans << endl << ansx << ' ' << ansy << ' ' << ansz;
}