N = gets.to_i
P = gets.split.map(&:to_i)

sorted = P.sort

count = 0
P.each_with_index do |p, i|
  if p != sorted[i]
    count += 1
  end
end

if count == 0 || count == 2
  puts 'YES'
else
  puts 'NO'
end
