n=int(eval(input()))

A=[0]*3

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

    A[i-1]+=1

dp=[[[0]*(n+2)for _ in range(n+2)]for __ in range(n+2)]

for i in range(A[2]+1):

    for j in range(n-A[0]-i+1):

        for k in range(n-i-j+1):

            if i+j+k!=0:

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

i,j,k=A

print((dp[k][j][i]))
def main():

    n=int(eval(input()))

    A=[0]*3

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

        A[i-1]+=1

    dp=[[[0]*(n+2)for _ in range(n+2)]for __ in range(n+2)]

    for i in range(A[2]+1):

        for j in range(n-A[0]-i+1):

            for k in range(n-i-j+1):

                if i+j+k!=0:

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

    i,j,k=A

    print((dp[k][j][i]))

main()
n = int(eval(input()))
A = [0] * 3
for i in map(int, input().split()):
    A[i - 1] += 1
dp = [[[0] * (n + 2) for _ in range(n + 2)] for __ in range(n + 2)]
for i in range(A[2] + 1):
    for j in range(n - A[0] - i + 1):
        for k in range(n - i - j + 1):
            if i + j + k != 0:
                dp[i][j][k] = (
                    dp[i - 1][j + 1][k] * i
                    + dp[i][j - 1][k + 1] * j
                    + dp[i][j][k - 1] * k
                    + n
                ) / (i + j + k)
i, j, k = A
print((dp[k][j][i]))

def main():
    n = int(eval(input()))
    A = [0] * 3
    for i in map(int, input().split()):
        A[i - 1] += 1
    dp = [[[0] * (n + 2) for _ in range(n + 2)] for __ in range(n + 2)]
    for i in range(A[2] + 1):
        for j in range(n - A[0] - i + 1):
            for k in range(n - i - j + 1):
                if i + j + k != 0:
                    dp[i][j][k] = (
                        dp[i - 1][j + 1][k] * i
                        + dp[i][j - 1][k + 1] * j
                        + dp[i][j][k - 1] * k
                        + n
                    ) / (i + j + k)
    i, j, k = A
    print((dp[k][j][i]))


main()

-n = int(eval(input())) -A = [0] * 3 -for i in map(int, input().split()): -    A[i - 1] += 1 -dp = [[[0] * (n + 2) for _ in range(n + 2)] for __ in range(n + 2)] -for i in range(A[2] + 1): -    for j in range(n - A[0] - i + 1): -        for k in range(n - i - j + 1): -            if i + j + k != 0: -                dp[i][j][k] = ( -                    dp[i - 1][j + 1][k] * i -                    + dp[i][j - 1][k + 1] * j -                    + dp[i][j][k - 1] * k -                    + n -                ) / (i + j + k) -i, j, k = A -print((dp[k][j][i])) +def main(): +    n = int(eval(input())) +    A = [0] * 3 +    for i in map(int, input().split()): +        A[i - 1] += 1 +    dp = [[[0] * (n + 2) for _ in range(n + 2)] for __ in range(n + 2)] +    for i in range(A[2] + 1): +        for j in range(n - A[0] - i + 1): +            for k in range(n - i - j + 1): +                if i + j + k != 0: +                    dp[i][j][k] = ( +                        dp[i - 1][j + 1][k] * i +                        + dp[i][j - 1][k + 1] * j +                        + dp[i][j][k - 1] * k +                        + n +                    ) / (i + j + k) +    i, j, k = A +    print((dp[k][j][i])) + + +main()