object Main extends App {
    var res = 0
    def solve(arr: Array[Int]): Unit = 
        if (arr.size > 1) {
            val a = arr.take(arr.size/2)
            val b = arr.drop(arr.size/2)
            solve(a)
            solve(b)
            a.foreach(c => res += b.count(_ < c))
        }
    val in = io.Source.stdin.getLines.map(_.split(" ").map(_.toInt))
    in.next
    solve(in.next)
    println(res)
}