#include #include #include #include using namespace std; double memo[101][101][101]; int n; double func(int a, int b, int c) { if (a==0 and b==0 and c==0) return 0; auto& res=memo[a][b][c]; // if (!isnan(res)) return res; if (res==res) return res; int s=a+b+c; res=(double)n/s; if (a) res+=func(a-1, b+1, c)*a/s; if (b) res+=func(a, b-1, c+1)*b/s; if (c) res+=func(a, b, c-1)*c/s; return res; } int main() { cin>>n; int m[3]={}; vector a(n); for(int& e: a) { cin>>e; if (e<3) m[e]++; } memset(memo, -1, sizeof(memo)); printf("%.9f\n", func(m[0], m[1], m[2])); }