import sys

def LI(): return [int(x) for x in sys.stdin.readline().split()]

def NI(): return int(sys.stdin.readline())





N = NI()

a = [0, 0, 0]

for x in LI():

    a[x-1] += 1

dp = [[[0.0] * (N+1) for _ in range(N+1)] for _ in range(N+1)]



for k in range(a[2]+1):

    for j in range(a[1]+a[2]+1):

        for i in range(N+1):

            if not (0 < i+j+k <= N):

                continue

            x = 0.0

            if i > 0:

                x += dp[i-1][j][k] * (i/N)

            if j > 0:

                x += dp[i+1][j-1][k] * (j/N)

            if k > 0:

                x += dp[i][j+1][k-1] * (k/N)

            x += 1.0

            x *= N / (i+j+k)

            dp[i][j][k] = x

print((dp[a[0]][a[1]][a[2]]))

import sys

input = sys.stdin.readline



n = int(eval(input()))

a = list(map(int, input().split()))

cnt = [0, 0, 0]

for ai in a:

    cnt[ai-1] += 1

p, q, r = cnt[0], cnt[1], cnt[2]



dp = [[[0.0] * (n + 1) for _ in range(n + 1)] for _ in range(n + 1)]



for k in range(r + 1):

    for j in range(r + q + 1):

        for i in range(n + 1):

            if not (0 < i + j + k <= n):

                continue

            tmp = 0.0

            if i > 0:

                tmp += dp[i - 1][j][k] * i

            if j > 0:

                tmp += dp[i + 1][j - 1][k] * j

            if k > 0:

                tmp += dp[i][j + 1][k - 1] * k

            tmp += n

            dp[i][j][k] = tmp / (i + j + k)



print((dp[p][q][r]))

import sys


def LI():
    return [int(x) for x in sys.stdin.readline().split()]


def NI():
    return int(sys.stdin.readline())


N = NI()
a = [0, 0, 0]
for x in LI():
    a[x - 1] += 1
dp = [[[0.0] * (N + 1) for _ in range(N + 1)] for _ in range(N + 1)]
for k in range(a[2] + 1):
    for j in range(a[1] + a[2] + 1):
        for i in range(N + 1):
            if not (0 < i + j + k <= N):
                continue
            x = 0.0
            if i > 0:
                x += dp[i - 1][j][k] * (i / N)
            if j > 0:
                x += dp[i + 1][j - 1][k] * (j / N)
            if k > 0:
                x += dp[i][j + 1][k - 1] * (k / N)
            x += 1.0
            x *= N / (i + j + k)
            dp[i][j][k] = x
print((dp[a[0]][a[1]][a[2]]))

import sys

input = sys.stdin.readline
n = int(eval(input()))
a = list(map(int, input().split()))
cnt = [0, 0, 0]
for ai in a:
    cnt[ai - 1] += 1
p, q, r = cnt[0], cnt[1], cnt[2]
dp = [[[0.0] * (n + 1) for _ in range(n + 1)] for _ in range(n + 1)]
for k in range(r + 1):
    for j in range(r + q + 1):
        for i in range(n + 1):
            if not (0 < i + j + k <= n):
                continue
            tmp = 0.0
            if i > 0:
                tmp += dp[i - 1][j][k] * i
            if j > 0:
                tmp += dp[i + 1][j - 1][k] * j
            if k > 0:
                tmp += dp[i][j + 1][k - 1] * k
            tmp += n
            dp[i][j][k] = tmp / (i + j + k)
print((dp[p][q][r]))

- -def LI(): -    return [int(x) for x in sys.stdin.readline().split()] - - -def NI(): -    return int(sys.stdin.readline()) - - -N = NI() -a = [0, 0, 0] -for x in LI(): -    a[x - 1] += 1 -dp = [[[0.0] * (N + 1) for _ in range(N + 1)] for _ in range(N + 1)] -for k in range(a[2] + 1): -    for j in range(a[1] + a[2] + 1): -        for i in range(N + 1): -            if not (0 < i + j + k <= N): +input = sys.stdin.readline +n = int(eval(input())) +a = list(map(int, input().split())) +cnt = [0, 0, 0] +for ai in a: +    cnt[ai - 1] += 1 +p, q, r = cnt[0], cnt[1], cnt[2] +dp = [[[0.0] * (n + 1) for _ in range(n + 1)] for _ in range(n + 1)] +for k in range(r + 1): +    for j in range(r + q + 1): +        for i in range(n + 1): +            if not (0 < i + j + k <= n): -            x = 0.0 +            tmp = 0.0 -                x += dp[i - 1][j][k] * (i / N) +                tmp += dp[i - 1][j][k] * i -                x += dp[i + 1][j - 1][k] * (j / N) +                tmp += dp[i + 1][j - 1][k] * j -                x += dp[i][j + 1][k - 1] * (k / N) -            x += 1.0 -            x *= N / (i + j + k) -            dp[i][j][k] = x -print((dp[a[0]][a[1]][a[2]])) +                tmp += dp[i][j + 1][k - 1] * k +            tmp += n +            dp[i][j][k] = tmp / (i + j + k) +print((dp[p][q][r]))