#include using namespace std; #define INF 100000000 #define YJ 1145141919 #define INF_INT_MAX 2147483647 #define INF_LL 9223372036854775 #define INF_LL_MAX 9223372036854775807 #define EPS 1e-10 #define MOD 1000000007 #define MOD9 998244353 #define Pi acos(-1) #define LL long long #define ULL unsigned long long #define LD long double #define int long long using II = pair; int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; } int lcm(int a, int b) { return a * b / gcd(a, b); } int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; } #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define ALL(a) begin((a)), end((a)) #define RALL(a) (a).rbegin(), (a).rend() #define PB push_back #define MP make_pair #define SZ(a) int((a).size()) const int MAX_N = 105; int N; int A[MAX_N]; int sumA[3]; double dp[MAX_N][MAX_N][MAX_N]; double solve(int i, int j, int k) { if(i == sumA[0] && j == sumA[1] & k == sumA[2]) { return 0.0; } if(i == 0 && j == 0 && k == 0) { return (solve(i,j,k+1) + 1) / N; } if(dp[i][j][k] >= 0.0) { return dp[i][j][k]; } double ret = 0.0; if(j-1 >= 0) { ret += solve(i+1,j-1,k) * (i+1) + (i+1); } if(k-1 >= 0) { ret += solve(i,j+1,k-1) * (j+1) + (j+1); } if(i+j+k+1 <= sumA[0] + sumA[1] + sumA[2]) { ret += solve(i,j,k+1) * (k+1) + (k+1); } return dp[i][j][k] = ret / (i+j+k); } signed main() { cin >> N; REP(n,N) { cin >> A[n]; if(A[n] >= 3) { continue; } else { sumA[A[n]]++; } } REP(i,MAX_N) { REP(j,MAX_N) { REP(k,MAX_N) { dp[i][j][k] = -1.0; } } } printf("%.15f\n", solve(0,0,0)); return 0; }