#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define mod (int)1000000007
#define P pair<int,int>
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define all(V) V.begin(),V.end()
#ifdef int
constexpr int INF = LLONG_MAX / 10;
#else
constexpr int INF = INT_MAX / 10;
#endif
constexpr double eps = DBL_EPSILON;
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
using namespace std;
inline int gcd(int a, int b) {
	while (b) {
		int c = a;
		a = b; b = c % b;
	}
	return a;
}
inline int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
bool isprime(int n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
int mypow(int a, int b) {
	if (!b)return 1;
	if (b & 1)return mypow(a, b - 1) * a;
	int memo = mypow(a, b >> 1);
	return memo * memo;
}
int modpow(int a, int b, int m = mod) {
	if (!b)return 1;
	if (b & 1)return modpow(a, b - 1, m) * a % m;
	int memo = modpow(a, b >> 1, m);
	return memo * memo % m;
}
template<typename T, typename U>
class SegTree {
	int n = 1;
	T* node = NULL;
	U* lazy = NULL;
	bool* lazyflag = NULL;
	T nodee;
	function<T(T, T)> nodef;
	function<U(U, U)> lazyf;
	function<T(T, U, int, int)> updf;
	void eval(int k, int l, int r) {
		if (lazyflag[k]) {
			node[k] = updf(node[k], lazy[k], l, r);
			if (r - l > 1) {
				if (lazyflag[2 * k + 1])lazy[2 * k + 1] = lazyf(lazy[2 * k + 1], lazy[k]);
				else lazy[2 * k + 1] = lazy[k];
				if (lazyflag[2 * k + 2])lazy[2 * k + 2] = lazyf(lazy[2 * k + 2], lazy[k]);
				else lazy[2 * k + 2] = lazy[k];
				lazyflag[2 * k + 1] = lazyflag[2 * k + 2] = true;
			}
			lazyflag[k] = false;
		}
	}
public:
	SegTree(int m, T init, T nodee, function<T(T, T)> nodef, function<U(U, U)> lazyf, function<T(T, U, int, int)> updf) :nodee(nodee), nodef(nodef), lazyf(lazyf), updf(updf) {
		delete[] node;
		delete[] lazy;
		while (n < m)n *= 2;
		node = new T[2 * n], lazy = new U[2 * n], lazyflag = new bool[2 * n];
		for (int i = n - 1; i < 2 * n - 1; i++)node[i] = init;
		for (int i = n - 2; i >= 0; i--)node[i] = nodef(node[2 * i + 1], node[2 * i + 2]);
		rep(i, 2 * n)lazyflag[i] = false;
	}
	SegTree(int m, T nodee, function<T(T, T)> nodef, function<U(U, U)> lazyf, function<T(T, U, int, int)> updf, vector<T> initvec) :nodee(nodee), nodef(nodef), lazyf(lazyf), updf(updf) {
		if (m != initvec.size()) {
			cerr << "Invalid Initialization of SegmentTree" << endl;
			exit(1);
		}
		delete[] node;
		delete[] lazy;
		while (n < m)n *= 2;
		node = new T[2 * n], lazy = new U[2 * n], lazyflag = new bool[2 * n];
		for (int i = n - 1; i < 2 * n - 1; i++) {
			if (i - n + 1 < m)node[i] = initvec[i - n + 1];
			else node[i] = nodee;
		}
		for (int i = n - 2; i >= 0; i--)node[i] = nodef(node[2 * i + 1], node[2 * i + 2]);
		rep(i, 2 * n)lazyflag[i] = false;
	}
	~SegTree() {
		delete[] node;
		delete[] lazy;
	}
	void update(int a, int b, U x, int k = 0, int l = 0, int r = -1) {
		if (r == -1)r = n;
		eval(k, l, r);
		if (b <= l || r <= a)return;
		if (a <= l && r <= b) {
			lazyflag[k] = true;
			lazy[k] = x;
			eval(k, l, r);
		}
		else {
			update(a, b, x, 2 * k + 1, l, (l + r) / 2);
			update(a, b, x, 2 * k + 2, (l + r) / 2, r);
			node[k] = nodef(node[2 * k + 1], node[2 * k + 2]);
		}
	}
	T query(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r == -1)r = n;
		eval(k, l, r);
		if (b <= l || r <= a)return nodee;
		if (a <= l && r <= b)return node[k];
		T vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
		T vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
		return nodef(vl, vr);
	}
};
class RAQRSQ :public SegTree<int, int> {
public:
	RAQRSQ(int size, const int& def = 0) :SegTree<int, int>(size, def, 0, [](int a, int b) {return a + b; }, [](int a, int b) {return a + b; }, [](int a, int b, int l, int r) {return a + (r - l) * b; }) {};
};
class RAQRMiQ :public SegTree<int, int> {
	using base = SegTree<int, int>;
public:
	RAQRMiQ(int size, const int& def = 0) :base(size, def, INF, [](int a, int b) {return min(a, b); }, [](int a, int b) {return a + b; }, [](int a, int b, int l, int r) {return a + b; }) {};
};
class RAQRMaQ :public SegTree<int, int> {
	using base = SegTree<int, int>;
public:
	RAQRMaQ(int size, const int& def = 0) :base(size, def, -INF, [](int a, int b) {return max(a, b); }, [](int a, int b) {return a + b; }, [](int a, int b, int l, int r) {return a + b; }) {};
};
class RUQRSQ :public SegTree<int, int> {
	using base = SegTree<int, int>;
public:
	RUQRSQ(int size, const int& def = 0) :base(size, def, 0, [](int a, int b) {return a + b; }, [](int a, int b) {return b; }, [](int a, int b, int l, int r) {return (r - l) * b; }) {};
};
class RUQRMiQ :public SegTree<int, int> {
	using base = SegTree<int, int>;
public:
	RUQRMiQ(int size, const int& def = 0) :base(size, def, INF, [](int a, int b) {return min(a, b); }, [](int a, int b) {return b; }, [](int a, int b, int l, int r) {return b; }) {};
};
class RUQRMaQ :public SegTree<int, int> {
	using base = SegTree<int, int>;
public:
	RUQRMaQ(int size, const int& def = 0) :base(size, def, -INF, [](int a, int b) {return max(a, b); }, [](int a, int b) {return b; }, [](int a, int b, int l, int r) {return b; }) {};
};
int n, a, b[3];
double dp[2][310][310][310];
signed main() {
	cin >> n;
	rep(i, n) {
		cin >> a;
		b[a - 1]++;
	}
	dp[0][b[0]][b[1]][b[2]] = 0;
	dp[1][b[0]][b[1]][b[2]] = 1;
	for (int k = b[2]; k >= 0; k--) {
		for (int j = b[1] + b[2]; j >= 0; j--) {
			for (int i = b[0] + b[1] + b[2]; i >= 0; i--) {
				if (dp[1][i][j][k] == 0)continue;
				dp[0][i][j][k] /= dp[1][i][j][k];
				if (i) {
					dp[0][i - 1][j][k] += (dp[0][i][j][k] + (double)n / (i + j + k)) * i / (i + j + k) * dp[1][i][j][k];
					dp[1][i - 1][j][k] += (double)i / (i + j + k) * dp[1][i][j][k];
				}
				if (j) {
					dp[0][i + 1][j - 1][k] += (dp[0][i][j][k] + (double)n / (i + j + k)) * j / (i + j + k) * dp[1][i][j][k];
					dp[1][i + 1][j - 1][k] += (double)j / (i + j + k) * dp[1][i][j][k];
				}
				if (k) {
					dp[0][i][j + 1][k - 1] += (dp[0][i][j][k] + (double)n / (i + j + k)) * k / (i + j + k) * dp[1][i][j][k];
					dp[1][i][j + 1][k - 1] += (double)k / (i + j + k) * dp[1][i][j][k];
				}
			}
		}
	}
	printf("%.12lf\n", dp[0][0][0][0]);
	return 0;
}

Measured memory_bytes: 452864