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

(n-1).times do |i|
  puts "i: #{i}"
  _cnt = cnt
  (n-1).downto(i+1) do |j|
    puts "j: #{j}"
    k = j - 1
    if a[k] > a[j]
      a[k], a[j] = a[j], a[k]
      cnt += 1
    end
  end
  break if cnt == _cnt
end

puts cnt