N = gets.chomp.to_i
P = gets.chomp.split.map(&:to_i)

# If increasing order, n is match with i (index)

diff = 0
0.upto(N-1).each do |i|
  n = P[i]
  if n != (i + 1)
    diff += 1
  end
end

if diff <= 2
  print "YES\n"
else
  print "NO\n"
end