def merge(arr,left,mid,right)
  p = mid - left
  q = right - mid
  l1 = arr[left,p]
  l2 = arr[mid,q]
  l1 << 1e10
  l2 << 1e10
  i = j = 0
  (left...right).map do |k|
    if l1[i] <= l2[j]
      arr[k] = l1[i]
      i += 1
    else
      arr[k] = l2[j]
      j += 1
      $cnt += p-i
    end
  end
end
def mergeSort(arr,left,right)
  if left + 1 < right
    mid = (left+right)/2
    mergeSort(arr,left,mid)
    mergeSort(arr,mid,right)
    merge(arr,left,mid,right)
  end
end
n = gets.to_i
arr = gets.split.map(&:to_i)
$cnt = 0
mergeSort(arr,0,n)
p $cnt