{-# LANGUAGE Strict #-}
import           Control.Monad               (forM_)
import qualified Data.ByteString.Char8       as B
import           Data.List                   (unfoldr)
import           Data.Vector.Unboxed         (Vector, (!))
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM

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 = countOccur as
        s = V.foldr' (\x y -> x * (x - 1) `div` 2 + y) 0 xs

countOccur :: [Int] -> Vector Int
countOccur as = V.create $ do
  v <- VM.new $ 2 * 10 ^ 5 + 1
  forM_ as $ \a -> VM.modify v succ a
  return v
