from collections import defaultdict

import sys

from functools import lru_cache

sys.setrecursionlimit(100000)

N = int(eval(input()))

 

counts = [0,0,0]

for a in map(int,input().split()):

  counts[a-1] += 1



A,B,C = counts





# dp[i][j][k] = 残り1個の皿がi枚、残り2個の皿がj枚、残り3個の皿がk枚のときの回数の期待値

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

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

dp = [[[None]*(C+1) for _ in range(B+C+1)] for _ in range(A+B+C+1)]

dp[0][0][0] = 0



for k in range(C+1):

  for j in range(B+C+1-k):

    for i in range(A+B+C+1-k-j):

      try:

        dp[i][j][k] =((i*dp[i-1][j][k] if i else 0)+

                      (j*dp[i+1][j-1][k] if j else 0)+

                      (k*dp[i][j+1][k-1] if k else 0)+

                      N)/(i+j+k)

      except ZeroDivisionError:

        pass



print((dp[A][B][C]))
from collections import defaultdict

N = int(eval(input()))

 

counts = [0,0,0]

for a in map(int,input().split()):

  counts[a-1] += 1



A,B,C = counts





# dp[i][j][k] = 残り1個の皿がi枚、残り2個の皿がj枚、残り3個の皿がk枚のときの回数の期待値

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

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

dp = [[[0]*(A+B+C+1-k-j) for j in range(B+C+1-k)] for k in range(C+1)]



t1 = None



for k in range(C+1):

  t0 = dp[k]

  for j in range(B+C+1-k):

    for i in range(A+B+C+1-k-j):

      try:

        dp[k][j][i] =((i*t0[j][i-1] if i else 0)+

                      (j*t0[j-1][i+1] if j else 0)+

                      (k*t1[j+1][i] if k else 0)+

                      N)/(i+j+k)

      except ZeroDivisionError:

        pass

  t1 = t0





print((dp[C][B][A]))
from collections import defaultdict
import sys
from functools import lru_cache

sys.setrecursionlimit(100000)
N = int(eval(input()))
counts = [0, 0, 0]
for a in map(int, input().split()):
    counts[a - 1] += 1
A, B, C = counts
# dp[i][j][k] = 残り1個の皿がi枚、残り2個の皿がj枚、残り3個の皿がk枚のときの回数の期待値
# dp[i][j][k] = (i/N)(dp[i-1][j][k])+(j/N)(dp[i+1][j-1][k])+(k/N)(dp[i][j+1][k-1])+(N-i-j-k/N)(dp[i][j][k])+1
# dp[i][j][k] = (i(dp[i-1][j][k])+j(dp[i+1][j-1][k])+k(dp[i][j+1][k-1])+N)/(i+j+k)
dp = [[[None] * (C + 1) for _ in range(B + C + 1)] for _ in range(A + B + C + 1)]
dp[0][0][0] = 0
for k in range(C + 1):
    for j in range(B + C + 1 - k):
        for i in range(A + B + C + 1 - k - j):
            try:
                dp[i][j][k] = (
                    (i * dp[i - 1][j][k] if i else 0)
                    + (j * dp[i + 1][j - 1][k] if j else 0)
                    + (k * dp[i][j + 1][k - 1] if k else 0)
                    + N
                ) / (i + j + k)
            except ZeroDivisionError:
                pass
print((dp[A][B][C]))

from collections import defaultdict

N = int(eval(input()))
counts = [0, 0, 0]
for a in map(int, input().split()):
    counts[a - 1] += 1
A, B, C = counts
# dp[i][j][k] = 残り1個の皿がi枚、残り2個の皿がj枚、残り3個の皿がk枚のときの回数の期待値
# dp[i][j][k] = (i/N)(dp[i-1][j][k])+(j/N)(dp[i+1][j-1][k])+(k/N)(dp[i][j+1][k-1])+(N-i-j-k/N)(dp[i][j][k])+1
# dp[i][j][k] = (i(dp[i-1][j][k])+j(dp[i+1][j-1][k])+k(dp[i][j+1][k-1])+N)/(i+j+k)
dp = [
    [[0] * (A + B + C + 1 - k - j) for j in range(B + C + 1 - k)] for k in range(C + 1)
]
t1 = None
for k in range(C + 1):
    t0 = dp[k]
    for j in range(B + C + 1 - k):
        for i in range(A + B + C + 1 - k - j):
            try:
                dp[k][j][i] = (
                    (i * t0[j][i - 1] if i else 0)
                    + (j * t0[j - 1][i + 1] if j else 0)
                    + (k * t1[j + 1][i] if k else 0)
                    + N
                ) / (i + j + k)
            except ZeroDivisionError:
                pass
    t1 = t0
print((dp[C][B][A]))

-import sys -from functools import lru_cache -sys.setrecursionlimit(100000) -dp = [[[None] * (C + 1) for _ in range(B + C + 1)] for _ in range(A + B + C + 1)] -dp[0][0][0] = 0 +dp = [ +    [[0] * (A + B + C + 1 - k - j) for j in range(B + C + 1 - k)] for k in range(C + 1) +] +t1 = None +    t0 = dp[k] -                dp[i][j][k] = ( -                    (i * dp[i - 1][j][k] if i else 0) -                    + (j * dp[i + 1][j - 1][k] if j else 0) -                    + (k * dp[i][j + 1][k - 1] if k else 0) +                dp[k][j][i] = ( +                    (i * t0[j][i - 1] if i else 0) +                    + (j * t0[j - 1][i + 1] if j else 0) +                    + (k * t1[j + 1][i] if k else 0) -print((dp[A][B][C])) +    t1 = t0 +print((dp[C][B][A]))