#include #define fst(t) std::get<0>(t) #define snd(t) std::get<1>(t) #define thd(t) std::get<2>(t) #define unless(p) if(!(p)) #define until(p) while(!(p)) using ll = std::int64_t; using P = std::tuple; int N; int A[100]; double dp[101][101][101]; double rec(int n0, int n1, int n2){ if(n0 + n1 + n2 == 0){ return 0; } double p0 = 1.0 * n0 / N, p1 = 1.0 * n1 / N, p2 = 1.0 * n2 / N, p = p0 + p1 + p2; double e = 1; if(n0 > 0){ e += p0 * rec(n0 - 1, n1 + 1, n2); } if(n1 > 0){ e += p1 * rec(n0, n1 - 1, n2 + 1); } if(n2 > 0){ e += p2 * rec(n0, n1, n2 - 1); } e /= p; return dp[n0][n1][n2] = e; } int main(){ std::cin.tie(nullptr); std::ios::sync_with_stdio(false); std::cin >> N; for(int i=0;i> A[i]; } std::fill(&dp[0][0][0], &dp[0][0][0] + 101 * 101 * 101, -1); double e = rec(std::count(A, A + N, 0), std::count(A, A + N, 1), std::count(A, A + N, 2)); printf("%.10f\n", e); }