#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using vi=vector<int>;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }

vector<int> Eratosthenes(int N){
	vector<int> arr(N,1);
    vector<int> res;
	for(int i = 2; i < sqrt(N); i++){
		if(arr[i]){
			for(int j = 0; i * (j + 2) < N; j++){
				arr[i *(j + 2)] = 0;
			}
		}
	}

	for(int i = 1; i < N; i++){
		if(arr[i]){
            res.push_back(i);
		}
	}
    return res;
}

const ll INF = 1LL << 60;
 
ll N;
vector<ll> a;
int main() {
    cin >> N;
    a.resize(N + 1);
    rep(i, N) cin >> a[i + 1];
    vector<ll> ans(N + 1, -1);
    for (int i = N; i > 0; i--) {
        int loop_cnt = N / i;
        if (loop_cnt >= 2) {
            ll tmp = 0;
            for (int j = i + i; j <= N; j += i) {
                tmp += ans[j];
            }
            tmp = tmp % 2;
            ans[i] = tmp ^ a[i];
        } else {
            ans[i] = a[i];
        }
    }
    set<ll> st;
    for (int i = 1; i <= N; i++) {
        if (ans[i] == 1) {
            st.insert(i);
        };
    }
 
    cout << st.size() << endl;
 
    for (auto v : st) {
        cout << v << " ";
    }
    cout << "\n";
}
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define uu unsigned
#define io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define MOD 1000000007
#define pl pair<ll,ll>
#define mkp make_pair
#define ss second
#define ff first
#define mit(a,b) map<a,b>::iterator
#define sit(a) set<a>::iterator
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define printcas cout<<"Case "<<cas<<": "
#define _ continue;
#define endl '\n'
#define __ cout<<endl;continue;
const ll oo=(1ll<<60);
int gi(){
	int x=0,w=1;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')w=0,ch=getchar();
	while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return w?x:-x;
}
vector<vector<vector<double>>> dp(305,vector<vector<double>>(305,vector<double>(305,-1.0)));
double n;
double e(double t1,double t2,double t3)
{
    if(dp[(int)t1][(int)t2][(int)t3]!=-1) return dp[(int)t1][(int)t2][(int)t3];
    return dp[(int)t1][(int)t2][(int)t3]=(1.0/(t1+t2+t3))*(n+((!t1)?0:(t1*e(t1-1.0,t2,t3)))+((!t2)?0:(t2*e(t1+1.0,t2-1.0,t3)))+((!t3)?0:(t3*e(t1,t2+1.0,t3-1.0))));
}
int main()
{
     //io;
    //string hudai(1000000,'a');
    int T=1;
    //T=gi();
     for(int cas=1;cas<=T;cas++)
    {
        double t1=0.0,t2=0.0,t3=0.0,x;
       cin>>n;
       for(int i=1;i<=n;i++)
       {
           cin>>x;
           if(x==1)t1+=1.0;
           else if(x==2) t2+=1.0;
           else t3+=1.0;
       }
//       int mx=max(t1,max(t2,t3));
//       for(int i=0;i<=n+2;i++)for(int j=0;j<=n+2;j++)for(int k=0;k<=n+2;k++)dp[i][j][k]=-1;
       dp[0][0][0]=0;
       printf("%.15lf",e(t1,t2,t3));

    }
    return 0;
}
