LearnPy Hub
← Arena
AdvancedRating 1700

Frog Crossing the River

Stones sit at the given increasing positions, the first at 0. The frog's first jump is 1 unit. If its last jump was k units, its next jump must be k − 1, k or k + 1 units (forward), and it must land on a stone. Can it reach the last stone? Print YES or NO.

Input

n (≤ 500), then n positions.

Output

YES or NO.

Sample 1

Input
8
0 1 3 5 6 8 12 17
Output
YES

Sample 2

Input
8
0 1 2 3 4 8 9 11
Output
NO
solution.py
Output appears here
Frog Crossing the River · Python Arena problem · LearnPy Hub