#include #include using namespace atcoder; using namespace std; using ll=long long; using ld=long double; ld pie=3.14159265359; ll mod=998244353; ll inf=99999999999999999; vector>>dp; ll n; ll one=0,two=0,thr=0; ld saiki(ll a,ll b,ll c){ if (a+b+c>n||a<0||b<0) { return 0; } if (dp[a][b][c]!=-1) { return dp[a][b][c]; } ld pl=(ld)n/(ld)(n-c); ld y=0; y+=(saiki(a+1,b,c)+pl)*((ld)(n-a-b-c)/(ld)(n-c)); y+=(saiki(a-1,b+1,c)+pl)*((ld)(a)/(ld)(n-c)); y+=(saiki(a,b-1,c+1)+pl)*((ld)(b)/(ld)(n-c)); dp[a][b][c]=y; return dp[a][b][c]; } int main(){ cin >> n; vectora(n); for (ll i = 0; i < n; i++) { cin >> a[i]; } ll one=0,two=0,thr=0; for (ll i = 0; i < n; i++) { if (a[i]==1) { one+=1; } if (a[i]==2) { two+=1; } if (a[i]>=3) { thr+=1; } } dp.assign(n+1,vector>(n+1,vector(n+1,-1))); dp[0][0][n]=0; cout << setprecision(20) << saiki(one,two,thr) << endl; }