let split_string ?(pattern="") = Str.split @@ Str.regexp pattern
let ($) f g = fun x -> g (f x)
let n = Scanf.sscanf (read_line ()) "%d" @@ fun n -> n
let s = Array.init n @@fun _ -> read_line () |> split_string |> List.sort compare |> String.concat ""

let rec f n = if n = 0 then 0 else n + f (n - 1)

let () = 
  Array.sort compare s;
  let a = Array.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 in
  a |> List.map (snd $ pred $ f) |> List.fold_left (+) 0 |> Printf.printf "%d\n"