def merge(a, left, mid, right)
	n1 = mid - left
	n2 = right - mid
	
	l = a[left..left+n1-1]
	r = a[mid..mid+n2-1]
	l[n1] = 10 ** 9
	r[n2] = 10 ** 9

	i = 0
	j = 0
	
	for k in left..right-1
		if l[i] < r[j]
			a[k] = l[i]
			i += 1
		else
			a[k] = r[j]
			j += 1
			
			$cnt += l.length - i - 1
		end
	end
end

def merge_sort(a, left, right)
	if left + 1 < right
		mid = (left + right) / 2
		merge_sort(a, left, mid)
		merge_sort(a, mid, right)
		merge(a, left, mid, right)
	end
end

n = gets.to_i
a = gets.split(" ").map(&:to_i)
$cnt = 0

merge_sort(a, 0, n)

puts $cnt