n=gets.to_i
p=gets.split.map &:to_i
cnt=0
p.each_with_index do |e,i|
    if e != i+1
        cnt += 1
        if cnt > 3
            break
        end
    end
end

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

