def merge as, left, mid, right
  l_as = as.slice(left..mid)
  r_as = as.slice((mid + 1)..right)
  l_as << Float::INFINITY
  r_as << Float::INFINITY

  l_i, r_i = [0, 0]
  cnt = 0
  left.upto(right) do |i|
    if l_as[l_i] <= r_as[r_i]
      as[i] = l_as[l_i]
      l_i += 1
    else
      cnt += (mid + 1 + r_i - i)
      as[i] = r_as[r_i]
      r_i += 1
    end
  end
  return cnt
end

def merge_sort as, left, right
  cnt = 0
  if left < right
    mid = (left + right) / 2
    cnt += merge_sort as, left, mid
    cnt += merge_sort as, mid + 1, right
    cnt += merge as, left, mid, right
  end
  return cnt
end

n = gets.chomp.to_i
as = gets.chomp.split(' ').map(&:to_i)
cnt = merge_sort as, 0, n - 1
puts cnt
