#ifndef _GLIBCXX_NO_ASSERT #include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if __cplusplus >= 201103L #include #include #include #include #include #include #include #include #endif // C++ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if __cplusplus >= 201103L #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #endif using namespace std; typedef long long ll; typedef pair Pint; typedef pair P; //typedef pair> P; //typedef tuple T; ll INFL = 1000000000000000010;//10^18 = 2^60 int INF = 2147483600;//10^9 ll MOD = 1000000007; //vector dy = {0,0,1,-1}; //vector dx = {1,-1,0,0}; int N; int A; double dp[110][110][110]; double solve(int x, int y, int z){ if(dp[x][y][z] != -1) return dp[x][y][z]; double exp_num = 1.0 * N / (N-z); double res = 0.0; if(x != N) res += (solve(x+1, y, z) + exp_num) * (N-x) / (N-z); if(y != x) res += (solve(x, y+1, z) + exp_num) * (x-y) / (N-z); if(z != y) res += (solve(x, y, z+1) + exp_num) * (y-z) / (N-z); return dp[x][y][z] = res; } int main(void){ cin >> N; int a = 0, b = 0, c = 0; for(int i = 0; i < N; i++){ int A; cin >> A; if(A >= 3) a++, b++, c++; else if(A >= 2) a++, b++; else if(A >= 1) a++; } for(int i = 0; i <= N; i++){ for(int j = 0; j <= N; j++){ for(int k = 0; k <= N; k++){ dp[i][j][k] = -1; } } } dp[N+1][N+1][N+1] = 0; cout << solve(a, b, c) << endl; }