#include "bits/stdc++.h" #define all(x) (x).begin(), (x).end() #define rep(i,a,b) for (int (i) = (a); (i) < (b); ++(i)) #define rrep(i,a,b) for (int (i) = (a); (i) >= (b); --(i)) using namespace std; typedef long long ll; const int INF = 1e9; const ll LINF = 1LL << 60; const ll MOD = 1e9 + 7; template bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } int N; int c0, c1, c2; double dp[110][110][110]; double dfs(int i, int j, int k) { if (dp[i][j][k] >= 0) return dp[i][j][k]; if (i == 0 && j == 0 && k == 0) return 0; double res = N; if (i > 0) res += dfs(i - 1, j + 1, k) * i; if (j > 0) res += dfs(i, j - 1, k + 1) * j; if (k > 0) res += dfs(i, j, k - 1) * k; res /= (double)(i + j + k); return dp[i][j][k] = res; } int main() { cin >> N; rep(i, 0, N) { int a; cin >> a; if (a == 0) ++c0; if (a == 1) ++c1; if (a == 2) ++c2; } memset(dp, -1, sizeof(dp)); cout << dfs(c0, c1, c2) << endl; return 0; }