class BIT
  attr_reader :bit, :size

  def initialize(size, init: 0)
    @bit = Array.new(size + 1, init)
    @size = size
  end

  def sum(i)
    s = 0

    while i > 0
      s += bit[i]
      i -= i & -i
    end

    s
  end

  def add(i, x)
    while i <= size
      bit[i] += x
      i += i & -i
    end
  end
end

class Array
  def inversion_number
    cnt = 0
    n = size
    bit = BIT.new(n)

    order = uniq.sort.map.with_index(1) do |v, i|
      [v, i]
    end.to_h

    n.times do |j|
      cnt += j - bit.sum(order[at(j)])
      bit.add(order[at(j)], 1)
    end

    cnt
  end
end

n = gets.to_i
a = gets.split.map(&:to_i)

puts a.inversion_number


