{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE LambdaCase #-}
module Main where

import           Data.List
import           Control.Monad
import           Debug.Trace
import qualified Data.ByteString.Char8         as BC
import           Data.Maybe                     ( fromJust )
import qualified Data.Set                      as S
import qualified Data.IntMap.Strict            as IM
import qualified Data.IntMap.Lazy            as IML
import qualified Data.Map.Strict               as M
import           Data.Char
import qualified Data.Array.IArray as A
import qualified Data.Array.Unboxed as UA
import Data.Bits
import Control.Monad.State.Strict
import qualified Data.Array.ST as STA
import qualified Data.Array.MArray as MA
import Control.Monad.ST

modN = 1000000007


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as =
    let (fo, la) = span f as
        las      = case la of
            [] -> []
            xs -> split f $ tail xs
    in  case fo of
            [] -> las
            xs -> xs : las

pow :: Int -> Int -> Int -> Int
pow base 1 modNum = base `mod` modNum
pow base time modNum
    | odd time = let 
        a = pow base (time `div` 2) modNum `mod` modNum
        in
        a * a * base `mod` modNum
    | otherwise = let
        a = pow base (time `div` 2) modNum `mod` modNum
        in
        a * a `mod` modNum

combi :: Integral a => a -> a -> a
combi n k
    | k > n = 0
    | n == k = 1
    | k > (n - k) = combi n (n - k)
    | otherwise = product [n, (n - 1)..(n - k + 1)] `div` product [1..k]

solve :: Int -> [Int] -> [Int]
solve n as = let
    arr = M.fromList $ zip [1..] as
    numMap =  foldr (M.alter $ \case
                        Nothing -> Just 1
                        Just x -> Just $ x + 1
                    ) M.empty as
    (combiMap, total) = foldl' (\(b, tot) a -> case M.lookup a numMap of
                                    Nothing  -> (b, tot)
                                    Just x -> let ansx = combi x 2
                                        in
                                        (M.insert a ansx b, tot + ansx)
                    ) (M.empty, 0) [1..n]
    ans x = let
        num = arr M.! x
        counter = numMap M.! num
        combiNum = combiMap M.! num
        in
            total - combiNum + combi (counter - 1) 2
    in
    ans <$> [1..n]


main :: IO ()
main = do
    n <- readInt
    as <- readInts
    forM_ (solve n as) print


