#include <bits/stdc++.h>
using namespace std;

#define int long long
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define fst first
#define snd second
#define ff first
#define st second
#define endl "\n"
#define pow2(x) (x*1LL*x)

void I_LOVE_PEREKOPSKA() {
    int n;
    cin>>n;
    vector<int> a(n);
    bool check2 = 1;
    for (auto &x:a) {
        cin>>x;
        check2 &= (x==1 || x==0);
    }
    vector<int> pt;
    if (n==3) {
        sort(all(a));
        cout<<a[2]-a[0]<<endl;
        cout<<"1 2 3\n";
        return;
    }
    if (check2) {
        int sm = count(all(a), 1);
        if (sm==1) {
            cout<<"1\n1 2 3\n";
            return;
        }
        if (sm==2) {
            cout<<"1\n";
            vector<int> ps;
            for (int i=0;i<n;i++) {
                if (a[i]==1) ps.pb(i+1);
            }
            string ttp = " ";
            int kkkk = -1;
            if (ps[0]==1) {
                if (ps[1]==n) ttp = " 2 ";
                else if (ps[1]!=n) kkkk = n;;
            }
            cout<<ps[0]<<ttp<<ps[1];
            if (kkkk!=-1) cout<<" "<<kkkk;
            return;
        }
        cout<<sm%3<<endl;
        int tp = 0;
        for (int i=0;i<n;i++) {
            tp+=a[i];
            if (tp==sm/3) {
                pt.pb(i+1);
                tp = 0;
            }
            if (pt.size()==2) break;
        }
        cout<<1<<" ";
        for (auto x:pt)
            cout<<x+1<<" ";
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    int t = 1;
    // cin>>t;
    while (t--) {
        I_LOVE_PEREKOPSKA();
    }
}