module Main where

import           Debug.Trace
import qualified Data.Vector.Unboxed           as VU
import           Data.List
import qualified Data.ByteString               as BS
import qualified Data.ByteString.Char8         as BSC8
import           Data.Char
import           Data.Maybe


getVUIntFromInputLineAtBSC8 :: IO (VU.Vector Int)
getVUIntFromInputLineAtBSC8 =
    VU.unfoldr (BSC8.readInt . BSC8.dropWhile isSpace) <$> BSC8.getLine
getVUListIntFromInputLineAtBSC8 =
    VU.unfoldr (BSC8.readInt . BSC8.dropWhile isSpace) <$> BSC8.getLine
readInt = fst . fromJust . BSC8.readInt
readIntList = map readInt . BSC8.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main :: IO [()]
main = do
    --s <- getLine
    --[aM,aN] <- getListIntFromInputLineAtBSC8
    --aP                   <- getVUIntFromInputLineAtBSC8
    --aQ                   <- getVUIntFromInputLineAtBSC8
    --aR                   <- getVUIntFromInputLineAtBSC8

    --vP <- VU.fromList . take aX . reverse . sort <$> getIntList
    --vQ <- VU.fromList . take aY . reverse . sort <$> getIntList
    --vR <- VU.fromList . take (aX + aY) . reverse . sort <$> getIntList

    aN <- getInt
    aA <- getIntList

    let aAP   = map (\x -> (x-1,1)) aA

    let cntAP = VU.accum (+) (VU.replicate aN 0) aAP

    let cntSum = foldl (\acc1 minus -> acc1 ++ [sumCon2 minus cntAP]) [] aA
    mapM (putStrLn . show) cntSum

sumCon2 :: Int -> VU.Vector Int -> Int
sumCon2 minus cntAP =
    let sumCnt = VU.accum (+) cntAP [(minus - 1, -1)]
    in  VU.foldl (\acc x -> acc + if x > 1 then con2 x else 0) 0 sumCnt

con2 :: Int -> Int
con2 x = div (x * (x - 1)) 2

fact :: Int -> Int
fact 1 = 1
fact x = x * fact (x - 1)

