#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; constexpr int INF = 1001001001; // constexpr int mod = 1000000007; constexpr int mod = 998244353; template inline bool chmax(T& x, T y){ if(x < y){ x = y; return true; } return false; } template inline bool chmin(T& x, T y){ if(x > y){ x = y; return true; } return false; } double dp[101][101][101]; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; vector cnt(3); for(int i = 0; i < N; ++i){ int A; cin >> A; if(A < 3) cnt[A] += 1; } for(int i = 0; i <= N; ++i){ for(int j = 0; j <= N; ++j){ for(int k = 0; k <= N; ++k){ dp[i][j][k] = -1; } } } auto func = [&](auto&& self, int i, int j, int k) -> double { if(dp[i][j][k] != -1) return dp[i][j][k]; if(i == 0 && j == 0 && k == 0) return dp[i][j][k] = 0; double res = 0; if(i > 0) res += self(self, i - 1, j + 1, k) * i; if(j > 0) res += self(self, i, j - 1, k + 1) * j; if(k > 0) res += self(self, i, j, k - 1) * k; res += N; res /= i + j + k; return dp[i][j][k] = res; }; cout << fixed << setprecision(15); cout << func(func, cnt[0], cnt[1], cnt[2]) << endl; return 0; }