#include using namespace std; namespace { typedef double real; typedef long long ll; template ostream& operator<<(ostream& os, const vector& vs) { if (vs.empty()) return os << "[]"; auto i = vs.begin(); os << "[" << *i; for (++i; i != vs.end(); ++i) os << " " << *i; return os << "]"; } template istream& operator>>(istream& is, vector& vs) { for (auto it = vs.begin(); it != vs.end(); it++) is >> *it; return is; } int N; vector A; void input() { cin >> N; A.resize(N); cin >> A; } map< tuple, real > cache; real f(int a, int b, int c) { if (a < 0 || b < 0 || c < 0) return 0; real s = a + b + c; if (s == 0) return 0; auto key = make_tuple(a, b, c); if (cache.count(key)) { return cache[key]; } //cerr << a << " " << b << " " << c << " -> " << (N / s) + (a / s * f(a - 1, b + 1, c) + b / s * f(a, b - 1, c + 1) + c / s * f(a, b, c - 1)) << endl; return cache[key] = (N / s) + (a / s * f(a - 1, b + 1, c) + b / s * f(a, b - 1, c + 1) + c / s * f(a, b, c - 1)); } void solve() { vector r(4, 0); for (int i = 0; i < N; i++) { int k = max(0, 3 - A[i]); r[k]++; } cout << f(r[3], r[2], r[1]) << endl; } } int main() { input(); solve(); return 0; }