{-# LANGUAGE BangPatterns #-}

import qualified Data.ByteString.Char8 as B
import Control.Monad
import Data.Array
import qualified Data.Vector.Unboxed as UV

main=do
    n<-readLn::IO Int
    as<-UV.unfoldr(B.readInt.B.dropWhile(<'!'))<$>B.getLine::IO (UV.Vector Int)
    print $ f (fromIntegral n) $ acc as

acc :: UV.Vector Int -> (Int,Int,Int)
acc as = (a1,a2,a3) where
    av = UV.accumulate (+) (UV.replicate 3 0) $ UV.concatMap ma as
    ma 1 = UV.singleton (0,1)
    ma 2 = UV.fromList [(0,1),(1,1)]
    ma 3 = UV.fromList [(0,1),(1,1),(2,1)]
    a1 = av UV.! 0
    a2 = av UV.! 1
    a3 = av UV.! 2

f n (!a1,!a2,!a3) = e ! (a1,a2,a3) where
    e = array ((0,0,0),(a1,a2,a3)) [((i,j,k),m i j k)|i<-[0..a1],j<-[0..min i a2],k<-[0..min j a3]]
    m 0 0 0 = 0.0
    m i j k = (e1+e2+e3+1) * n / fromIntegral i where
        e1 |i>j = e ! (i-1,j,k) * fromIntegral (i-j) / n |otherwise = 0.0
        e2 |j>k = e ! (i,j-1,k) * fromIntegral (j-k) / n |otherwise = 0.0
        e3 |k>0 = e ! (i,j,k-1) * fromIntegral k     / n |otherwise = 0.0
