module Main where

import           Control.Monad
import           Debug.Trace
import qualified Data.Vector.Unboxed           as VU
import           Data.List
import qualified Data.ByteString               as BS
import qualified Data.ByteString.Char8         as BSC8
import           Data.Char
import           Data.Maybe

tuplify2 (x:y:_) = (x,y)
tuplify2 _ = undefined

getVUIntFromInputLineAtBSC8 :: IO (VU.Vector Int)
getVUIntFromInputLineAtBSC8 =
    VU.unfoldr (BSC8.readInt . BSC8.dropWhile isSpace) <$> BSC8.getLine
getVUListIntFromInputLineAtBSC8 =
    VU.unfoldr (BSC8.readInt . BSC8.dropWhile isSpace) <$> BSC8.getLine

readInt = fst . fromJust . BSC8.readInt
readIntTuple = tuplify2 . map readInt . BSC8.words
readIntList = map readInt . BSC8.words

getInt = readInt <$> BSC8.getLine
getIntList = readIntList <$> BSC8.getLine
getIntNList n = map readIntList <$> replicateM (fromIntegral n) BSC8.getLine
getIntMatrix = map readIntList . BSC8.lines <$> BS.getContents
getIntTuple = readIntTuple <$> BSC8.getLine
getIntNTuples n = map readIntTuple <$> replicateM (fromIntegral n) BSC8.getLine
getIntTuples = map readIntTuple . BSC8.lines <$> BSC8.getContents

main :: IO [()]
main = do

    aN <- getInt
    aA <- getIntList

    let aAP    = map (\x -> (x - 1, 1)) aA

    let cntAP  =  VU.accum (+) (VU.replicate aN 0) aAP
    let combiCntAp = VU.map (con2) cntAP
    let sum = VU.sum combiCntAp
    let cntSum = map (\x -> sum - (combiCntAp VU.! (x-1)) + (con2 (cntAP VU.! (x-1) - 1 ))) aA
    mapM (putStrLn . show) cntSum

con2 :: Int -> Int
con2 0 = 0
con2 1 = 0
con2 x = div (x * (x - 1)) 2

