object Main extends App {
    var res = 0L
    def msort(arr: Array[Int]): Array[Int] = {
        if (arr.size > 1) {
            val a = msort(arr.take(arr.size/2))
            val b = msort(arr.drop(arr.size/2))
            var i, j, k = 0
            var f = true
            while (f)
                if (i == a.size && j == b.size) f = false
                else if (j == b.size || (i != a.size && a(i) < b(j))) {arr(k) = a(i); i += 1; k += 1}
                else {arr(k) = b(j); j += 1; k += 1; if (i != a.size) res += (a.size-i)}
        }
        arr
    }
    val in = io.Source.stdin.getLines.map(_.split(" ").map(_.toInt))
    in.next
    msort(in.next)
    println(res)
}