#include<bits/stdc++.h>
using namespace std;
#define int  long long int
#define fi first
#define se second
#define pb push_back
#define soo(v) sort(v.rbegin(),v.rend())
#define so(v) sort(v.begin(),v.end())
#define lb(v,x) lower_bound(v.begin(),v.end(),x)
#define ub(v,x) upper_bound(v.begin(),v.end(),x)
#define endl '\n'
#define dbv(v) cout<<endl;cout<<#v<<"-->> ";for(auto it:v){cout<<it<<" ";}cout<<endl;
#define dbm(m)cout<<endl;cout<<#m<<"-->> ";for(auto it:m){cout<<it.fi<<" "<<it.se.fi<<" "<<it.se.se<<endl;}
#define dbs(s)cout<<endl;cout<<#s<<"-->> ";for(auto it:s){cout<<it<<" ";}cout<<endl;
#define mod 1000000007
#define db1(x) cout<<#x<<"="<<x<<endl;
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl;
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<endl;
#define mx 1e18
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v)  *min_element(v.begin(),v.end())
#define double long double
int powe(int x,int n)
{
  if(n==0)return 1;
  if(n%2==0)
    return powe((x%mod*x%mod)%mod,n/2)%mod;
  return (x%mod*powe((x%mod*x%mod)%mod,(n-1)/2))%mod;
}
int gcd(int A,int B)
{
  if(B==0)return A;
  return gcd(B,A%B);
}
#define io std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define re(s) reverse(s.begin(),s.end())
int32_t main()
{
    io
int a;
cin>>a;
cout<<a*(1+a+a*a)<<endl;
}
#include <bits/stdc++.h>
using namespace std;
double solve(vector<vector<vector<double>>> &dp,int a, int b, int c, int n) {
  if (dp[a][b][c]) return dp[a][b][c];
  if (!a&&!b&&!c) return 0;
  dp[a][b][c] = 1.0*n/(a+b+c);
  if (a) dp[a][b][c] += solve(dp,a-1,b,c,n)*a/(a+b+c);
  if (b) dp[a][b][c] += solve(dp,a+1,b-1,c,n)*b/(a+b+c);
  if (c) dp[a][b][c] += solve(dp,a,b+1,c-1,n)*c/(a+b+c);
  return dp[a][b][c];
}
int main() {
  int N;
  cin >> N;
  int ones = 0, twos = 0, threes = 0, a;
  vector<vector<vector<double>>> dp(N+1,vector<vector<double>>(N+1,vector<double>(N+1)));
  for (int i = 0; i < N; i++) {
    cin >> a;
    ones += a == 1;
    twos += a == 2;
    threes += a == 3;
  }
  cout.precision(20);
  cout << solve(dp,ones,twos,threes,N);
}