#include using namespace std; #ifdef LOCAL_DEBUG #include "LOCAL_DEBUG.hpp" #endif #define int long long template vector make_vec(size_t a) { return vector(a); } template auto make_vec(size_t a, Ts... ts) { return vector(ts...))>(a, make_vec(ts...)); } template typename enable_if::value == 0>::type fill(T &t, const V &v) { t = v; } template typename enable_if::value != 0>::type fill(T &t, const V &v){ for (auto &e : t) fill(e, v); } // auto v = make_vec(h, w); // fill(v, 0); signed main(){ int n; cin >> n; vector a(n), cnt(4, 0); for(int i = 0; i < n; i++){ cin >> a[i]; cnt[min(3LL, a[i])]++; } auto dp = make_vec(n+1, n+1, n+1); fill(dp, -1); dp[0][0][0] = 0; function< double(int,int,int) > rec = [&](int a, int b, int c){ if(dp[a][b][c] != -1) return dp[a][b][c]; double E = 1.0 * n / (a + b + c); if(a > 0) E += rec(a-1, b+1, c) * a / (a + b + c); if(b > 0) E += rec(a, b-1, c+1) * b / (a + b + c); if(c > 0) E += rec(a, b, c-1) * c / (a + b + c); return dp[a][b][c] = E; }; printf("%.9f\n",rec(cnt[0], cnt[1], cnt[2])); return 0; }