require 'pp'

n = gets.chomp!.to_i
p_n = gets.chomp!.split(" ").map(&:to_i)

diff_count = 0

p_n.each.with_index(1) do |i, n|
    if i != n
        diff_count +=1
    end
end

if diff_count <= 2
    puts "YES"
else
    puts "NO"
end
