n = gets.to_i
d = gets.chomp.split.map(&:to_i)

sorting = d.sort

count = 0

i = 0

while i < n
	if d[i] != sorting[i]
		count += 1
	end
	i += 1
end

if count == 0 || count == 2
	puts 'YES'
else
	puts 'NO'
end