n = $stdin.gets.chomp.to_i
arr = $stdin.gets.chomp.split(" ")
arr.map! do |a_j|
a_j.to_i
end

arr2 = []

for i in 1..n
    arr2.push i
end

count = 0

for i in 0.. n - 1
  if arr[i] != arr2[i]
    count += 1
  end
end

if count == 2 or count == 0
    puts "YES"
else
    puts "NO"
end