n = gets.chomp.to_i
arr = gets.chomp.split.map(&:to_i)
flag = true
(n-1).times do |i|
	flag = false if arr[i] > arr[i+1]
end
if flag 
	puts "YES"
	exit
end

def check(n, arr)
	(n-1).times do |i|
		if arr[i] > arr[i + 1]
			return false
		end
	end
	return true
end

(n-1).times do |i|
	(i+1..n-1).each do |j|
		arr[i], arr[j] = arr[j], arr[i]
		if check(n, arr)
			puts "YES"
			exit
		end
		arr[i], arr[j] = arr[j], arr[i]
	end
end
puts "NO"
