import Data.List
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)
import qualified Data.IntMap as IM

type Map = IM.IntMap Integer

getLines :: IO [String]
getLines = map (sort . BC.unpack) . BC.lines <$> BC.getContents

factorial :: Int -> Map -> (Integer, Map)
factorial 1 cm = (1, cm)
factorial n cm = case IM.lookup n cm of
  Just x -> (x, cm)
  Nothing -> (r, nm)
    where r = fromIntegral n * fst (factorial (n - 1) cm)
          nm = IM.insert n r cm

combies :: Map -> Int -> Integer
combies im n
  | n <= 1 = 0
  | n == 2 = 1
  | otherwise = r
    where r = case IM.lookup n im of
                Just x -> x
                Nothing -> fst (factorial n im) `div` 2 * fst (factorial (n - 2) im)

main :: IO ()
main = do
  getLine
  ls <- getLines
  print . sum . map (combies IM.empty . length) $ group $ sort ls
