n = gets.chomp.to_i
plist = gets.chomp.split.collect{ |item| item.to_i}

count = 0
plist.each_with_index do |pi,i|
  if (pi != (i+1))
    count += 1
  end
end

if (count == 0 || count == 2)
  puts "YES"
else
  puts "NO"
end