object ALDS1_5_D extends App {
  var count = 0

  def merge(a: Vector[Int], b: Vector[Int]): Vector[Int] = (a,b) match {
    case (_, Vector()) => a
    case (Vector(), _) => b
    case (ah+:at, bh+:bt) =>
      if (ah <= bh) ah +: merge(at, b)
      else {count += a.length; bh +: merge(a, bt)}
  }

  def msort(l: Vector[Int]): Vector[Int] = {
    if (l.length > 1) {
      val (x,y) = l.splitAt(l.length/2)
      val xx = msort(x)
      val yy = msort(y)
      merge(xx,yy)
    } else {
      l
    }
  }

  val n = io.StdIn.readLine()
  val l = io.StdIn.readLine().split(' ').toVector map (_.toInt)
  msort(l)
  println(count)
}