n = gets.chomp.to_i
array = gets.split.map(&:to_i)
count = 0
(n - 1).times do |i|
  if array[i] != array[i + 1] - 1
    count += 1
  end
  if count == 3
    break
  end
end
if count == 2 || count == 0
  puts "YES"
else
  puts "NO"
end