n = int(eval(input()))

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

for thr in range(n + 1):

	for two in range(n + 1):

		for one in range(n + 1):

			su = thr + two + one

			if su > n or su == 0:

				continue

			#変更が起こるのに必要な回数の期待値

			dp[thr][two][one] += n / su

			#（各遷移先の期待値）×重み

			if thr:

				dp[thr][two][one] += dp[thr - 1][two + 1][one] * thr / su

			if two:

				dp[thr][two][one] += dp[thr][two - 1][one + 1] * two / su

			if one:

				dp[thr][two][one] += dp[thr][two][one - 1] * one / su

a = b = c = 0

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

	if x == 3:

		a += 1

	elif x == 2:

		b += 1

	elif x == 1:

		c += 1

print((dp[a][b][c]))
def main():

	n = int(eval(input()))

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

	for thr in range(n + 1):

		for two in range(n + 1):

			for one in range(n + 1):

				su = thr + two + one

				if su > n or su == 0:

					continue

				dp[thr][two][one] += n / su

				if thr:

					dp[thr][two][one] += dp[thr - 1][two + 1][one] * thr / su

				if two:

					dp[thr][two][one] += dp[thr][two - 1][one + 1] * two / su

				if one:

					dp[thr][two][one] += dp[thr][two][one - 1] * one / su

	a = b = c = 0

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

		if x == 3:

			a += 1

		elif x == 2:

			b += 1

		elif x == 1:

			c += 1

	print((dp[a][b][c]))



if __name__ == "__main__":

	main()
n = int(eval(input()))
dp = [[[0] * (n + 1) for _ in range(n + 1)] for _ in range(n + 1)]
for thr in range(n + 1):
    for two in range(n + 1):
        for one in range(n + 1):
            su = thr + two + one
            if su > n or su == 0:
                continue
            # 変更が起こるのに必要な回数の期待値
            dp[thr][two][one] += n / su
            # （各遷移先の期待値）×重み
            if thr:
                dp[thr][two][one] += dp[thr - 1][two + 1][one] * thr / su
            if two:
                dp[thr][two][one] += dp[thr][two - 1][one + 1] * two / su
            if one:
                dp[thr][two][one] += dp[thr][two][one - 1] * one / su
a = b = c = 0
for x in map(int, input().split()):
    if x == 3:
        a += 1
    elif x == 2:
        b += 1
    elif x == 1:
        c += 1
print((dp[a][b][c]))

def main():
    n = int(eval(input()))
    dp = [[[0] * (n - k - j + 1) for j in range(n - k + 1)] for k in range(n + 1)]
    for thr in range(n + 1):
        for two in range(n + 1):
            for one in range(n + 1):
                su = thr + two + one
                if su > n or su == 0:
                    continue
                dp[thr][two][one] += n / su
                if thr:
                    dp[thr][two][one] += dp[thr - 1][two + 1][one] * thr / su
                if two:
                    dp[thr][two][one] += dp[thr][two - 1][one + 1] * two / su
                if one:
                    dp[thr][two][one] += dp[thr][two][one - 1] * one / su
    a = b = c = 0
    for x in map(int, input().split()):
        if x == 3:
            a += 1
        elif x == 2:
            b += 1
        elif x == 1:
            c += 1
    print((dp[a][b][c]))


if __name__ == "__main__":
    main()

-n = int(eval(input())) -dp = [[[0] * (n + 1) for _ in range(n + 1)] for _ in range(n + 1)] -for thr in range(n + 1): -    for two in range(n + 1): -        for one in range(n + 1): -            su = thr + two + one -            if su > n or su == 0: -                continue -            # 変更が起こるのに必要な回数の期待値 -            dp[thr][two][one] += n / su -            # （各遷移先の期待値）×重み -            if thr: -                dp[thr][two][one] += dp[thr - 1][two + 1][one] * thr / su -            if two: -                dp[thr][two][one] += dp[thr][two - 1][one + 1] * two / su -            if one: -                dp[thr][two][one] += dp[thr][two][one - 1] * one / su -a = b = c = 0 -for x in map(int, input().split()): -    if x == 3: -        a += 1 -    elif x == 2: -        b += 1 -    elif x == 1: -        c += 1 -print((dp[a][b][c])) +def main(): +    n = int(eval(input())) +    dp = [[[0] * (n - k - j + 1) for j in range(n - k + 1)] for k in range(n + 1)] +    for thr in range(n + 1): +        for two in range(n + 1): +            for one in range(n + 1): +                su = thr + two + one +                if su > n or su == 0: +                    continue +                dp[thr][two][one] += n / su +                if thr: +                    dp[thr][two][one] += dp[thr - 1][two + 1][one] * thr / su +                if two: +                    dp[thr][two][one] += dp[thr][two - 1][one + 1] * two / su +                if one: +                    dp[thr][two][one] += dp[thr][two][one - 1] * one / su +    a = b = c = 0 +    for x in map(int, input().split()): +        if x == 3: +            a += 1 +        elif x == 2: +            b += 1 +        elif x == 1: +            c += 1 +    print((dp[a][b][c])) + + +if __name__ == "__main__": +    main()