n = read_line.to_i a = read_line.split.map(&.to_i) puts a.each_with_index.sum { |x, i| a[i + 1..].count { |y| x > y } }