{-# 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 (\a -> s - xs ! a + 1) as
  where xs = M.fromListWith (+) [(a, 1) | a <- as]
        s = M.foldr' (\x y -> x * (x - 1) `div` 2 + y) 0 xs
