from collections import Counter

import sys

input = sys.stdin.buffer.readline



def main():

    n = int(eval(input()))

    m = float(n)

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

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

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

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

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

                if i + j + k == 0:

                    continue

                tmp = m

                if i > 0:

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

                if j > 0:

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

                if k > 0:

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

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

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



if __name__ == '__main__':

    main()

n = int(eval(input()))

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

uno = a.count(1)

dos = a.count(2)

tres = n - uno - dos

dp = [[[.0]*(n+1) for _ in range(dos+tres+1)] for j in range(tres+1)]

for k in range(tres+1):

  for j in range(dos+tres-k+1):

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

      if i+j+k == 0: continue

      v = i+j+k

      res = n

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

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

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

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

print((dp[tres][dos][uno])) 

from collections import Counter
import sys

input = sys.stdin.buffer.readline


def main():
    n = int(eval(input()))
    m = float(n)
    a = Counter(list(map(int, input().split())))
    dp = [[[0.0] * (n + 1) for _ in range(n + 1)] for _ in range(n + 1)]
    for k in range(a[3] + 1):
        for j in range(a[2] + a[3] - k + 1):
            for i in range(n - j - k + 1):
                if i + j + k == 0:
                    continue
                tmp = m
                if i > 0:
                    tmp += i * dp[i - 1][j][k]
                if j > 0:
                    tmp += j * dp[i + 1][j - 1][k]
                if k > 0:
                    tmp += k * dp[i][j + 1][k - 1]
                dp[i][j][k] = tmp / (i + j + k)
    print((dp[a[1]][a[2]][a[3]]))


if __name__ == "__main__":
    main()

n = int(eval(input()))
a = list(map(int, input().split()))
uno = a.count(1)
dos = a.count(2)
tres = n - uno - dos
dp = [[[0.0] * (n + 1) for _ in range(dos + tres + 1)] for j in range(tres + 1)]
for k in range(tres + 1):
    for j in range(dos + tres - k + 1):
        for i in range(n + 1 - j - k):
            if i + j + k == 0:
                continue
            v = i + j + k
            res = n
            if i:
                res += i * dp[k][j][i - 1]
            if j:
                res += j * dp[k][j - 1][i + 1]
            if k:
                res += k * dp[k - 1][j + 1][i]
            dp[k][j][i] = res / v
print((dp[tres][dos][uno]))

-from collections import Counter -import sys - -input = sys.stdin.buffer.readline - - -def main(): -    n = int(eval(input())) -    m = float(n) -    a = Counter(list(map(int, input().split()))) -    dp = [[[0.0] * (n + 1) for _ in range(n + 1)] for _ in range(n + 1)] -    for k in range(a[3] + 1): -        for j in range(a[2] + a[3] - k + 1): -            for i in range(n - j - k + 1): -                if i + j + k == 0: -                    continue -                tmp = m -                if i > 0: -                    tmp += i * dp[i - 1][j][k] -                if j > 0: -                    tmp += j * dp[i + 1][j - 1][k] -                if k > 0: -                    tmp += k * dp[i][j + 1][k - 1] -                dp[i][j][k] = tmp / (i + j + k) -    print((dp[a[1]][a[2]][a[3]])) - - -if __name__ == "__main__": -    main() +n = int(eval(input())) +a = list(map(int, input().split())) +uno = a.count(1) +dos = a.count(2) +tres = n - uno - dos +dp = [[[0.0] * (n + 1) for _ in range(dos + tres + 1)] for j in range(tres + 1)] +for k in range(tres + 1): +    for j in range(dos + tres - k + 1): +        for i in range(n + 1 - j - k): +            if i + j + k == 0: +                continue +            v = i + j + k +            res = n +            if i: +                res += i * dp[k][j][i - 1] +            if j: +                res += j * dp[k][j - 1][i + 1] +            if k: +                res += k * dp[k - 1][j + 1][i] +            dp[k][j][i] = res / v +print((dp[tres][dos][uno]))