
#include <bits/stdc++.h>
//#pragma GCC optimize("O3")

using namespace std;
typedef long long ll;
const ll dim=700007;
ll n,a[dim],T[dim],b[dim], c[dim], p[dim],p1,p2,p3;
string s;
map<ll,ll>mp;
/*ll build(int v, int tl, int tr){
   if(tl==tr){
        T[v]=a[tl];
        return T[v];
   }
   int tm=(tl+tr)>>1;

    T[v]=build(2*v+1, tl, tm)+build(2*v+2, tm+1, tr);
}

ll get(int v, int tl, int tr, int l, int r)
void solve(){
    cin>>n;
}*/
void solve(){
    cin>>n;
     ll sum=0;
    for(int i=1; i<=n; i++){cin>>a[i]; sum+=a[i];}
     p[0]=0;

        for(int i=1; i<=n; i++)p[i]=p[i-1]+a[i];
         ll need=sum/3;
         ll curr=0;
         //if(sum%3)need++;

         p1=1;
         p2=0;
         p3=0;
        for(int i=1; i<=n; i++){
               curr+=a[i];

               mp[curr]=i;


               if(mp[curr-need]!=0){
                p1=mp[curr-need];
                p2=i;
                break;
               }
        }
        curr=0;
        for(int i=p2; i<=n; i++){
              curr+=a[i];

              if(curr==need)p3=i+1;
        }



    cout << 0 << endl  << p1 << " " << p2 << " " << p3 << endl;




}
int main()
{

    int t;
    t=1;
   // cin>>t;
    while(t--)solve();

    return 0;
}
