$num = gets.to_i

a = gets.chomp
$a = a.split()
$b = []
for i in 1..$num do
	$b[i-1] = $a[i-1].to_i
end


$n = 0

$c = []
def merge(left,right)
	if(left >= right)
		return
	end

	mid = (left + right) / 2
	merge(left,mid)
	merge(mid + 1,right)
	
	for i in left..mid do
		$c[i] = $b[i]
	end

	j = right
	for i in mid + 1..right
		$c[i] = $b[j]
		j = j - 1
	end

	i = left
	j = right 

	for k in left..right do
		if $c[i] <= $c[j]
			$b[k] = $c[i]
			i = i + 1
		else
			$n = $n + mid + 1 - i
			$b[k] = $c[j]
			j = j - 1
		end
	end
end

merge(0,$num-1)

puts $n