object Main extends App {
  import scala.collection.mutable.{ArrayBuffer, ArrayOps}

  var count: Long = 0
  val n = io.StdIn.readLine()
  val arr: collection.mutable.ArrayOps[Int] = split(io.StdIn.readLine())

  def split(str: String): Array[Int] = {
    val buf: ArrayBuffer[Int] = ArrayBuffer.empty[Int]
    var num_builder = 0
    val iter = str.toIterator

    while(iter.hasNext) {
      val v = iter.next()
      if (v != ' ') num_builder = num_builder*10 + v.toInt
      else {buf += num_builder; num_builder = 0}
    }
    (buf += num_builder).toArray
  }

  def merge(left: Int, middle: Int, right: Int): Unit = {
    val l = arr.slice(left, middle)
    val r = arr.slice(middle, right)
    val lLen = l.length
    val rLen = r.length

    var i = left
    var li = 0
    var ri = 0

    while(li < lLen && ri < rLen) {
      if (l(li) <= r(ri)) {
        arr(i) = l(li)
        i += 1
        li += 1
      } else {
        arr(i) = r(ri)
        count += (lLen - li)
        i += 1
        ri += 1
      }
    }

    if (li < lLen) while (li < lLen) {arr(i) = l(li); i += 1; li += 1}
    else while (ri < rLen) {arr(i) = r(ri); i += 1; ri += 1}
  }

  def msort(left: Int, right: Int): Unit = {
    val middle = (left+right+1)/2
    if (middle < right) {
      msort(left, middle)
      msort(middle, right)
      merge(left, middle, right)
    } else {
      ()
    }
  }

  msort(0, arr.length)
  println(count)
}