def method_name(n, ps)
  cnt = 0
  ps.each_with_index do |v, i|
    cnt += 1 if v != i+1
    return "NO" if cnt > 2
  end
  return "NO" if cnt == 1
  return "YES"
end

n = gets.chomp.to_i
ps = gets.chomp.split(" ").map(&:to_i)
puts method_name(n, ps)