import Control.Monad
import Data.Array
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Maybe
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

calc a [] = 0
calc a (t : ts)
  | a == num = (cnt - 1) * (cnt - 2) `div` 2 + calc a ts
  | otherwise = cnt * (cnt - 1) `div` 2 + calc a ts
  where
    num = fst t
    cnt = snd t

simulate as i ts table = do
  p <- VUM.read table i
  if p == 0
    then do
      let p' = calc (as ! i) ts
      print p'
      VUM.write table i p'
    else print p
  when (length as /= i) $ simulate as (i + 1) ts table

main = do
  n <- getInt
  as <- getIntList
  let ts = [(head x, length x) | x <- group (sort as)]
  let as' = listArray (1, length as) as
  table <- VUM.replicate (n + 1) 0 :: IO (VUM.IOVector Int)
  simulate as' 1 ts table
