{-# LANGUAGE BangPatterns #-}

import           Control.Applicative
import           Control.Monad
import           Debug.Trace

inv :: [Int] -> Int
inv xs = go 0 xs
  where
    go !k []     = k
    go !k [_]    = k
    go !k (y:ys) = go (k + length (filter (< y) ys)) ys

main :: IO ()
main = do
    getLine
    xs <- fmap read . words <$> getLine
    print $ inv xs

