gets.to_i
array = gets.split.map(&:to_i)
sorted = array.sort

diff_count = 0

array.each_with_index do |n, i|
  diff_count += 1 if n != sorted[i]
end

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