import scala.io.StdIn._

object Main extends App {
  val n = readLine.toInt
  val s = readLine.toList

  val MOD = 1000000007
  val values: List[Int] = s.groupBy(identity).mapValues(_.length).values.toList

  def combination(res: List[List[Int]], list: List[Int]): List[List[Int]] = list match {
    case Nil => res
    case h :: t => combination(res.map(l => h +: l) ++ res, t)
  }

  val res = combination(List(List()), values)
    .filter(!_.isEmpty)
    .map(l => l.foldLeft(1)((acc, h) => acc * h % MOD))
    .foldLeft(0)((acc, h) => (acc + h) % MOD)

  println(res)
}