import Data.List
import Data.Char
import Data.Maybe
import Control.Monad
import qualified Data.Vector as Vector
import Data.Vector ((!))
import qualified Data.ByteString.Char8 as BS8

main :: IO ()
main = do
  n <- fst . fromJust . BS8.readInt <$> BS8.getLine
  a <- unfoldr (BS8.readInt . BS8.dropWhile isSpace) <$> BS8.getLine

  let
    al = map (\x -> (x - 1, 1)) a
    l = Vector.accum (+) (Vector.replicate n 0) al
    s = sum $ Vector.map (\x -> x * (x - 1) `div` 2) l

  mapM_ (\x -> print $ s - ((l ! (x - 1)) * ((l ! (x - 1)) - 1) `div` 2) + (((l ! (x - 1)) - 1) * ((l ! (x - 1)) - 2) `div` 2)) a
