Problem: There are N dishes, numbered 1, 2, \ldots, N. Initially, for each i (1 \leq i \leq N), Dish i has a_i (1 \leq a_i \leq 3) pieces of sushi on it.

Taro will perform the following operation repeatedly until all the pieces of sushi are eaten:

* Roll a die that shows the numbers 1, 2, \ldots, N with equal probabilities, and let i be the outcome. If there are some pieces of sushi on Dish i, eat one of them; if there is none, do nothing.



Find the expected number of times the operation is performed before all the pieces of sushi are eaten.

Constraints

* All values in input are integers.
* 1 \leq N \leq 300
* 1 \leq a_i \leq 3

Input

Input is given from Standard Input in the following format:


N
a_1 a_2 \ldots a_N


Output

Print the expected number of times the operation is performed before all the pieces of sushi are eaten. The output is considered correct when the relative difference is not greater than 10^{-9}.

Examples

Input

3
1 1 1


Output

5.5


Input

1
3


Output

3


Input

2
1 2


Output

4.5


Input

10
1 3 2 3 3 2 3 2 1 3


Output

54.48064457488221

Solution (in JAVA):

Solution:
/**
 * @author derrick20
 */
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String args[]) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        // Trust me, you'll thank me later...
        double N = sc.nextDouble();
        int ones = 0;
        int twos = 0;
        int threes = 0;
        for (int i = 0; i < N; i++) {
            switch (sc.nextInt()) {
                case 1:
                    ones++;
                    break;
                case 2:
                    twos++;
                    break;
                case 3:
                    threes++;
                    break;
            }
        }
        double[][][] dp = new double[(int) N + 1][(int) N + 1][(int) N + 1];
        // At most N = 300, so 100^3 = 10^6 run time.
        // dp[i][j][k] = expected number of moves until reaching 0, 0, 0 left

        for (int k = 0; k <= N; k++) {
            for (int j = 0; j <= N; j++) {
                for (int i = 0; i <= N; i++) {
                    // Our recurrence is dp[i][j][k] = 1 + p(take from 1 pile) * 1 piles + ...
                    if (i == 0 && j == 0 && k == 0 || (i + j + k) > N) continue;

                    // Two approaches here:
                    // Here's the fun way:
                    // Geometric series of repeatedly taking from a zero pile, then finally taking a nonzero pile
                    // q = 1 - p
                    // p * [q + 2q^2 + 3q^3 + ...]
                    // = (1 - p) / p
                    // Prove this! But then, after we have played for an expected amount of time,
                    // then finally successfully picked something nonzero, we still need to pick
                    // WHICH nonzero plate is valid
                    double conditionalSpace = i + j + k;
                    double pSuccess = conditionalSpace / N;
                    double expectedSteps = (1 - pSuccess) / pSuccess;
                    dp[i][j][k] = expectedSteps; // So, we take these steps and eventually stop.
                    // Now, we look at all possibilities in the conditionalSpace and go from there
                    if (i > 0) {
                        // Take from 1 => i-1, j, k
                        dp[i][j][k] += (i / conditionalSpace) * (1 + dp[i - 1][j][k]);
                    }
                    if (j > 0) {
                        // Take from 2 => i+1, j-1, k!
                        dp[i][j][k] += (j / conditionalSpace) * (1 + dp[i + 1][j - 1][k]);
                    }
                    if (k > 0) {
                        // Take from 3 => i, j+1, k-1!
                        dp[i][j][k] += (k / conditionalSpace) * (1 + dp[i][j + 1][k - 1]);
                    }

                    // There's the last possibility of taking a zero, so we just add another step
                    /*
                    // The simpler way is to write out the expected value equations and simplify
                    // to get rid of the E_ijk term on both sides

                    if (i > 0) {
                        // Take from 1 => i-1, j, k
                        dp[i][j][k] += (i / N) * (dp[i - 1][j][k]);
                    }
                    if (j > 0) {
                        // Take from 2 => i+1, j-1, k!
                        dp[i][j][k] += (j / N) * (dp[i + 1][j - 1][k]);
                    }
                    if (k > 0) {
                        // Take from 3 => i, j+1, k-1!
                        dp[i][j][k] += (k / N) * (dp[i][j + 1][k - 1]);
                    }


                    dp[i][j][k]++;
                    dp[i][j][k] *= (N / (i + j + k));
                    */


                }
            }
        }
//        for (int i = 0; i <= ones; i++) {
//            for (int j = 0; j <= twos; j++) {
//                for (int k = 0; k <= threes; k++) {
//                    System.out.println("Expected moves until 0,0,0 from " + i + " " + j + " " + k + " : " + dp[i][j][k]);
//                }
//            }
//        }
        out.println(dp[ones][twos][threes]);
        out.close();
    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        FastScanner(FileReader s) {
            br = new BufferedReader(s);
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        String nextLine() throws IOException { return br.readLine(); }

        double nextDouble() throws IOException { return Double.parseDouble(next()); }

        int nextInt() throws IOException { return Integer.parseInt(next()); }

        long nextLong() throws IOException { return Long.parseLong(next()); }
    }
}