object Main extends App {
    val in = io.Source.stdin.getLines.map(_.split(" ").map(_.toInt))
    val n = in.next.head
    val x = in.next
    var res = 0L
    def msort(s: Int, e: Int): Unit = {
        if (e-s > 0) {
            msort(s, (s+e)/2)
            msort((s+e)/2+1, e)
            var i = s
            var j = (s+e)/2+1
            var k = 0
            val tmp = Array.fill(e-s+1)(0)
            var f = true
            while (f)
                if (i > (s+e)/2 && j > e) f = false
                else if (j > e || (i <= (s+e)/2 && x(i) < x(j))) {tmp(k) = x(i); i += 1; k += 1}
                else {tmp(k) = x(j); j += 1; k += 1; res += ((s+e)/2-i+1)}
            tmp.copyToArray(x, s)
        }
    }
    msort(0, n-1)
    println(res)
}