
#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;
/*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=n/3;
         ll curr=0;

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

               if(curr==need){
                curr=0;
                if(!p2)p2=i;
                else p3=i;
                continue;
               }
        }


       if(sum%3)cout << 1 << endl;
       else cout << 0 << endl;
    cout  << p1 << " " << p2 << " " << p3 << endl;


}
int main()
{

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

    return 0;
}
