n = gets.to_i
numbers = (1..n).to_a
array = gets.chomp.split(" ").map(&:to_i)
flag = []
answer = "NO"

array.each_index do |number|
  if array[number] != numbers[number]
    flag.push(number)
  end
end

if flag.length == 2 && array.swap(flag.first, array.last) == numbers
  answer = "YES"
end

puts answer