import Data.List (sort, foldl')

main :: IO ()
main = do
  n <- read <$> getLine
  s <- getLine
  let
    s' = map length . group . sort $ s
    c = foldl' step 1 s' - 1
    step a i = mod (a * (i + 1)) d
  print c

d :: Integer
d = 10 ^ 9 + 7
