let split_string ?(pattern="") = Str.split @@ Str.regexp pattern
let n = Scanf.sscanf (read_line ()) "%d" @@ fun n -> n
let s = read_line () |> split_string |> List.sort compare

let m_1e9 = int_of_float 1e9 + 7
let ( +^ ) x y = (x + y) mod m_1e9
let ( -^ ) x y = x - y + if x < y then m_1e9 else 0
let ( *^ ) x y = ((x mod m_1e9) * (y mod m_1e9)) mod m_1e9

let ss = List.fold_left (fun acc n ->
  match acc with
    | [] -> [(n, 1)]
    | (v, cnt) as t :: xs -> if v = n then (v, cnt + 1) :: xs else (n, 1) :: t :: xs
) [] s

let () = 
    Printf.printf "%d\n" @@ List.fold_left (fun sum (_, i) -> sum *^ (i + 1)) 1 ss -^ 1