import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import qualified Data.Vector.Unboxed as VU

main :: IO ()
main = do
  (n : _) <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  as <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  let
    ls = VU.accum (+) (VU.replicate n 0) . map (flip (,) 1 . pred) $ as :: VU.Vector Int
    m = VU.sum . VU.map comb $ ls :: Int
  mapM_ print . map ((m -) . pred . (ls VU.!) . pred) $ as

comb :: Int -> Int
comb l = (l * pred l) `div` 2

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
