object Main {
    var res = 0
    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) {arr(k) = a(i); i += 1; k += 1}
                else if (i == a.size) {arr(k) = b(j); j += 1; k += 1}
                else if (a(i) < b(j)) {arr(k) = a(i); i += 1; k += 1}
                else {arr(k) = b(j); j += 1; k += 1; res += (a.size-i)}
            }
        }
        arr
    }
    def main(args: Array[String]) = {
        val in = io.Source.stdin.getLines.map(_.split(" ").map(_.toInt))
        in.next
        msort(in.next)
        println(res)
    }
}