import Data.List
import qualified Data.Map as M

comb :: Int -> Int
comb n = n * (n-1) `div` 2

calc :: [(Int, Int)] -> Int -> Maybe Int
calc xs k =
    let v = lookup k xs
    in (-) <$> fmap comb v <*> fmap (comb . (\x -> x-1)) v

solve :: [Int] -> [Int]
solve xs = map (h . g . f) xs
    where ys = map (\x -> (head x, length x)) . group . sort $ xs
          t = sum . map (comb . snd) $ ys
          mp = M.fromList ys
          f k = M.lookup k mp
          g (Just v) = comb v - comb (v-1)
          h x = t - x


main :: IO ()
main = getLine >> getLine >>= mapM_ print . solve . map read . words