def bsort(a,n)
  cnt=0
  n.times do |i|
    if a[i]>a[i+1] then
      a[i],a[i+1]=a[i+1],a[i]
      cnt+=1
    end
  end
  if n>1 then
    cnt+=bsort(a,n-1)
  end
  return cnt
end

n=gets.to_i
a=gets.split.map!{|i|i.to_i}
a.slice!(n..-1)
cnt=bsort(a,n-1)
print cnt
