def merge(a, left, mid, right)
  n1 = mid - left
  n2 = right - mid
  l = (0..n1).to_a
  r = (0..n2).to_a
  0.upto(n1-1).each {|i| l[i] = a[left+i]}
  0.upto(n2-1).each {|i| r[i] = a[mid+i]}
  l[n1] = Float::INFINITY
  r[n2] = Float::INFINITY
  i = 0
  j = 0
  count = 0
  left.upto(right - 1).each {|k|
    if l[i] <= r[j]
      a[k] = l[i]
      i += 1
    else
      a[k] = r[j]
      j += 1
      count += n1 - i
    end
  }
  count
end

def merge_sort(a, left, right)
  return 0 unless left + 1 < right
  mid = (left + right) / 2
  count = merge_sort(a, left, mid)
  count += merge_sort(a, mid, right)
  count += merge(a, left, mid, right)
  count
end

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

count = merge_sort(s, 0, n)
puts count