def p_j_dp():

    n = int(eval(input()))

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

    c1 = a.count(1)

    c2 = a.count(2)

    c3 = a.count(3)

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

    for k in range(c3 + 1):

        for j in range(c3 + c2 + 1 - k):

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

                if i + j + k == 0:

                    continue

                res = n

                if i > 0:

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

                if j > 0:

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

                if k > 0:

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

                res /= i + j + k

                dp[i][j][k] = res

    print((dp[c1][c2][c3]))

    

p_j_dp()
def p_j_dp():

    n = int(eval(input()))

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

    c1 = a.count(1)

    c2 = a.count(2)

    c3 = a.count(3)

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

    for k in range(c3 + 1):

        for j in range(c3 + c2 + 1 - k):

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

                if i + j + k == 0:

                    continue

                res = n

                if i > 0:

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

                if j > 0:

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

                if k > 0:

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

                res /= i + j + k

                dp[i][j][k] = res

    print((dp[c1][c2][c3]))

    

p_j_dp()
def p_j_dp():
    n = int(eval(input()))
    (*a,) = list(map(int, input().split()))
    c1 = a.count(1)
    c2 = a.count(2)
    c3 = a.count(3)
    dp = [[[0] * (n + 1) for _ in range(n + 1)] for _ in range(n + 1)]
    for k in range(c3 + 1):
        for j in range(c3 + c2 + 1 - k):
            for i in range(n + 1 - k - j):
                if i + j + k == 0:
                    continue
                res = n
                if i > 0:
                    res += i * dp[i - 1][j][k]
                if j > 0:
                    res += j * dp[i + 1][j - 1][k]
                if k > 0:
                    res += k * dp[i][j + 1][k - 1]
                res /= i + j + k
                dp[i][j][k] = res
    print((dp[c1][c2][c3]))


p_j_dp()

def p_j_dp():
    n = int(eval(input()))
    (*a,) = list(map(int, input().split()))
    c1 = a.count(1)
    c2 = a.count(2)
    c3 = a.count(3)
    dp = [[[0.0] * (n + 1) for _ in range(n + 1)] for _ in range(n + 1)]
    for k in range(c3 + 1):
        for j in range(c3 + c2 + 1 - k):
            for i in range(n + 1 - k - j):
                if i + j + k == 0:
                    continue
                res = n
                if i > 0:
                    res += i * dp[i - 1][j][k]
                if j > 0:
                    res += j * dp[i + 1][j - 1][k]
                if k > 0:
                    res += k * dp[i][j + 1][k - 1]
                res /= i + j + k
                dp[i][j][k] = res
    print((dp[c1][c2][c3]))


p_j_dp()

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