import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as MP
import Control.Monad

step :: MP.Map B.ByteString Int -> B.ByteString -> MP.Map B.ByteString Int
step mp x = MP.insertWith (+) x 1 mp

step' :: Int -> Int -> Int
step' acc v
    | v == 1 = acc
    | otherwise = acc + sum [1..v-1]

main = do
    n <- readLn :: IO Int
    xs <- V.replicateM n (B.sort <$> B.getLine) :: IO (V.Vector B.ByteString)
    let mp = V.foldl' step MP.empty xs
    print $ MP.foldl step' 0 mp
