printРабочее место участника

printЗадачи

406. Cards

Ограничения: время – 1s/2s, память – 32MiB Ввод: input.txt или стандартный ввод Вывод: output.txt или стандартный вывод copy
Послать решение Blockly Посылки Темы Где Обсудить (0)

Each of the `n` cards has numbers written on the both sides of it. The first card has 0 and 1 on it, the second – 1 and 2, …, the `n`-th – (`n`-1) and `n`. First-grade pupil Nick takes cards one by one in random order and reads the number on one of the sides. Nick is not very good with numbers, so it is possible that he makes a mistake. Your task is to find out if he was mistaken, i.e. if the given sequence of numbers is possible for some order of taking cards.
Input
The first line of the input file contains numbers `n` – the total number of cards (`1\ ≤\ n\ ≤\ 1000`) and `m` (`1\ ≤\ m\ ≤\ n`) – the number of the cards that were taken.
Starting with the second line, the `m` positive integer numbers are listed (the sequence read by Nick). One or more spaces or CR/LF characters separate the numbers.
Output
Write "YES" to the output file if the given sequence of numbers is possible for some order of taking cards, "NO" otherwise.

Sample Input

5 4
2 0 1 2

Sample Output

NO
loading