n = gets.to_i
nums = gets.to_s.split(' ').map(&:to_i)
@cumulative_sums = (1...n).map { |i| nums[i - 1] - nums[i] }

def search
  idx = 0
  while idx < @cumulative_sums.size
    prev = @cumulative_sums[idx - 1]
    now = @cumulative_sums[idx]
    return 'No' if prev > 1 || now > 1
    return 'No' if prev == 1 && now == 1

    idx += 1
    idx += 1 while now.zero? && @cumulative_sums[idx] == now
    return 'No' if prev == 1 && @cumulative_sums[idx] == 1
  end
  'Yes'
end

puts search
