#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n;
vector<ll> v;
ll res;
vector<ll>res2;
ll p[1000007];
ll solve(ll i,ll t)
{
    ll l = i;
    ll r = n-1;
    while (l<=r)
    {
        ll mid = (l+r)/2;
        ll x = 0;
        if (i==0) x = p[mid];
        else x = p[mid] - p[i-1];
        if (x>t)
        {
            r = mid-1;
        }
        else if (x<t) l = mid+1;
        else return mid;
    }
    return -1;
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >>n;
    v.resize(n);
    ll s = 0;
    for(int i=0;i<n;i++)
    {
        cin >>v[i];
        //v.push_back(v[i]);
        s+=v[i];
        p[i] = s;
    }
    ll t = s/3;
    res = 0;
    res2.resize(3);
    for (int i=0;i<n;i++)
    {
        ll x = solve(i,t);
        if (x==-1) continue;
        else
        {
            ll y = solve(x+1,t);
            if (y!=-1)
            {
                res2[0] = i;
                res2[1] = x+1;
                res2[2] = (y+1)%n;
            }
        }
    }
    cout <<0<<endl;
    sort(res2.begin(),res2.end());
    cout <<res2[0]+1<<" "<<res2[1]+1<<" "<<res2[2]+1;


}
