MAX_VALUE =10 ** 9 + 1
$count = 0

def merge(array, left, mid, right)
  array_left = array[left..mid]
  array_right = array[mid+1..right]
  array_left << MAX_VALUE
  array_right << MAX_VALUE
  l = 0
  r = 0
  sorted = []

  (right-left+1).times do 
    if (array_left[l] > array_right[r]) then
      sorted << array_right[r]
      $count += (array_left.size - 1 -l)
      r += 1
    else
      sorted << array_left[l]
      l += 1
    end
  end

  array[left, right-left+1] = sorted
end

def merge_sort(array, left, right)
  mid = (left + right) / 2
  if (right - left > 1) then
    merge_sort(array, left, mid)
    merge_sort(array, mid+1, right)
    merge(array, left, mid, right)
  elsif (right - left == 1) then
    merge(array, left, mid, right)
  end
end

n = gets.chomp.to_i
array = gets.chomp.split.map(&:to_i)
merge_sort(array, 0, n-1)
puts $count