n = gets.chomp!.to_i
#ns = Array.new
is = gets.split.map(&:to_i)
count = 0
is.each_with_index do |value, key|
  #print(count, key, value, "\n")
  if value != key+1
    count += 1
  end
end

if count == 2 || count == 0
  print("YES\n")
else
  print("NO\n")
end