a = gets.to_i
problem_sort = gets.split(" ").map(&:to_i)
count = 0

num_sort = problem_sort.sort
a.times do |target|
  if problem_sort[target] != num_sort[target]
   count += 1
  end
end

if count <= 2
  puts "YES"
else
  puts "NO"
end