#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int main(){
    int n;cin>>n;
    vector<int> a(n);
    int cou1=0;
    int cou2=0;
    for (int i=0;i<n;i++){
        int b;cin>>b;
        a[i]=b;
        if (b==1){
            cou1++;
        }else{
            cou2++;
        }
    }
    if (cou1%3==0){
        cout<<0<<endl;
        cout<<1<<" ";
        int cur=0;
        int cou=1;
        for (int i=0;i<n;i++){
            cur+=a[i];
            if (cur==cou1/3 && cou<3){
                cout<<i+2<<" ";
                cur=0;
                cou++;
            }
        }
    }else{
        cout<<1<<endl;
        cout<<1<<" ";
        int cur=0;
        int cou=1;
        for (int i=0;i<n;i++){
            cur+=a[i];
            if (cur==cou1/3 && cou==1){
                cout<<i+2<<" ";
                cur=0;
                cou++;
            }else if (cur==cou1/3+1 && (cou==2)){
                cout<<i+2<<" ";
                cur=0;
                cou++;
            }
        }
    }
    return 0;
}