{-# LANGUAGE Strict #-}
import qualified Data.ByteString.Char8 as B
import           Data.IntMap.Strict    ((!))
import qualified Data.IntMap.Strict    as M
import           Data.List             (unfoldr)

main :: IO ()
main = do
  n <- readLn
  as <- readIntsLn
  putStr . unlines . map show $ solve n as

readIntsLn :: IO [Int]
readIntsLn = unfoldr (B.readInt . B.dropWhile (== ' ')) <$> B.getLine

solve :: Int -> [Int] -> [Int]
solve _ as = map f as
  where xs = M.fromListWith (+) [(a, 1) | a <- as]
        ys = M.map comb2 xs
        s = sum $ M.elems ys
        f a = s - y + comb2 (x - 1)
          where x = xs ! a
                y = ys ! a

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