integer N
integer,allocatable,dimension(:)::a
integer one,two,three
double precision::DP(0:301,0:301,0:301)
read*,N
allocate(a(n))
read*,a
one=0;two=0;three=0
do i=1,N
  if(a(i)==1)one=one+1
  if(a(i)==2)two=two+1
  if(a(i)==3)three=three+1
end do

DP=-1
DP(0,0,0)=0
print*,ans(one,two,three)

contains
recursive function ans(i,j,k) result(res)
  integer i,j,k
  double precision res
  if(DP(i,j,k)/=-1)then
    res=DP(i,j,k)
  else
    res=0
    if (i > 0) res =res + ans(i-1, j, k) * i
    if (j > 0) res =res + ans(i+1, j-1, k) * j
    if (k > 0) res =res + ans(i, j+1, k-1) * k
    res=res+N
    res=res*1.0/(i+j+k)
    DP(i,j,k)=res
  endif
end function ans
end