N = int(input()) A = list(map(int, input().split())) dp = [[[-1] * (N + 1) for _ in range(N + 1)] for _ in range(N + 1)] dp[N][N][N] = 0 for k in range(N, -1, -1): for j in range(N, k - 1, -1): for i in range(N, j - 1, -1): if k == N: continue elif j == N: dp[i][j][k] = (1 + dp[i][j][k + 1] * (j - k) / N) * N / (N - k) elif j == N: dp[i][j][k] = ( (dp[i + 1][j][k] * (N - i) / N + dp[i][j][k + 1] * (j - k) / N) * N / (N - k) ) elif i == N: dp[i][j][k] = ( (1 + dp[i][j + 1][k] * (i - j) / N + dp[i][j][k + 1] * (j - k) / N) * N / (N - k) ) else: dp[i][j][k] = ( ( 1 + dp[i + 1][j][k] * (N - i) / N + dp[i][j + 1][k] * (i - j) / N + dp[i][j][k + 1] * (j - k) / N ) * N / (N - k) ) i, j, k = 0, 0, 0 for a in A: if a >= 3: i += 1 j += 1 k += 1 elif a >= 2: i += 1 j += 1 elif a >= 1: i += 1 print(dp[i][j][k])