f = readlines
N = f[0].to_i
ary = f[1].split(" ").map(&:to_i)

i = 0
ans = 0

while i < N
  if ary[i] != (i + 1)
    ans += 1
  end
  i += 1
end

if ans == 0 ||ans ==2
  puts "YES"
else
  puts "NO"
end
