toInt :: (String -> Int)
toInt x = read x ::Int

getInts = do
    x <- getLine
    let y = (map$toInt)$words x
    return y

combinationsN :: Int -> [a] -> [[a]]
combinationsN 0 _      = [[]]
combinationsN _ []     = []
combinationsN n (x:xs) = (x:) `map` (combinationsN (n-1) xs) ++ combinationsN n xs

comb :: Int -> Int -> Int
comb k r
    | k < r = 0
    | otherwise = length $ (combinationsN r (take k [1..]))

resultFunc :: [Int] -> Int -> Int -> Int
resultFunc cs n a = sum $ map (\x -> if (a == fst x) then (comb ((snd x) - 1) 2) else (comb (snd x) 2)) (zip (take n [1..]) cs)

    

main = do
    n <- getInts
    as <- getInts
    let cs = map (\i -> length $ filter (\x -> x == i) as) (take (head n) [1..])
    let r = map (resultFunc cs (head n)) as
    sequence $ map print r
