import Data.Char
import Data.List
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector as V
main=mapM_ print.solve.unfoldr(B.readInt.B.dropWhile isSpace)=<<B.getContents
solve(n:as)=snd$mapAccumL f(1,1)[1..n+1]where
  k=(\[i,j]->n-j+i)$(elemIndices=<<head.head.filter((1<).length).group.sort)as
  f(c1,c2)i=((c12,c22),(c12+m-c2)`mod`m)where
    [c12,c22]=map(\(c,j)->c*(j-i+1)`mod`m*inv V.! i`mod`m)[(c1,n+1),(c2,k)]
  inv=V.generate(n+2)$ \i->if i<2 then 1 else inv V.!(m`mod`i)*(m-m`div`i)`mod`m
m=10^9+7