n = gets.to_i
s = gets.split.map(&:to_i)
$co = 0

class Array
  def merge_sort
    merge = ->(a, b) {
      result = []
      while a.size > 0 and b.size > 0
        result << if a[0] < b[0]
          a.shift
        else
          $co += a.size
          b.shift
        end
      end
      result + a + b
    }
    
    l = length
    return self if l <= 1
    q = l / 2
    merge.(self[0...q].merge_sort, self[q..-1].merge_sort)
  end
end

s.merge_sort
puts $co
