#!/usr/bin/ruby
#encoding: utf-8

n = gets.to_i
p = gets.split.map(&:to_i)
errornum = 0
(1..n).each do |i|
  if i != p[i-1] 
    errornum += 1
  end
end

if (errornum == 0) or (errornum == 2)
  puts "YES"
else
  puts "NO"
end
