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   = [ (x - 1, 1) | x <- aA ] :: [(Int, Int)]

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

    putStrLn $show cntAP

    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)

judgeCombi :: Int -> Int -> VU.Vector Int -> Int -> Int
judgeCombi target n cntAP minus =
    let combiList = getCombiList target n
    in
        foldl
            (\acc1 first ->
                acc1
                    + (foldl
                          (\acc2 second ->
                              acc2
                                  + (if (judge first second minus cntAP)
                                        then 1
                                        else 0
                                    )
                          )
                          0
                          combiList
                      )
            )
            0
            combiList

getCombiList :: Int -> Int -> [(Int, Int)]
getCombiList target n
    | target == n = []
    | otherwise = foldl
        (\acc x -> acc ++ if (x < (target - x)) then [(x, target - x)] else [])
        []
        [(max 1 (target - n)) .. (min n (target - 1))]

judge :: (Int, Int) -> (Int, Int) -> Int -> VU.Vector Int -> Bool
judge z a y cntAP =
    let
        pointList =
            [ (fst z - 1, 1)
            , (snd z - 1, 1)
            , (fst a - 1, 1)
            , (snd a - 1, 1)
            , (y - 1    , 1)
            ]
        sumAP = trace (show cntAP ++ show pointList)
            $ VU.accum (-) (cntAP) pointList
        ret = VU.foldl (\acc x -> acc && (if x >= 0 then True else False))
                       True
                       sumAP
    in
        trace (show ret) $ ret
