AtCoder Beginner Contest 136
C
Build Stairs
AtCoder
⌀ 295
原题
← BD →
翻译中…

Problem Statement

翻译中…

There are $N$ squares arranged in a row from left to right. The height of the $i$-th square from the left is $H_i$.

翻译中…

For each square, you will perform either of the following operations once:

翻译中…
  • Decrease the height of the square by $1$.
  • Do nothing.
翻译中…

Determine if it is possible to perform the operations so that the heights of the squares are non-decreasing from left to right.

翻译中…

Constraints

翻译中…
  • All values in input are integers.
  • $1 \leq N \leq 10^5$
  • $1 \leq H_i \leq 10^9$
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N
H_1 H_2 ... H_N

翻译中…

Output

翻译中…

If it is possible to perform the operations so that the heights of the squares are non-decreasing from left to right, print Yes; otherwise, print No.

翻译中…

样例

Input #1
5
1 2 1 1 3
Output #1
Yes
You can achieve the objective by decreasing the height of only the second square from the left by $1$.
Input #2
4
1 3 2 1
Output #2
No
Input #3
5
1 2 3 4 5
Output #3
Yes
Input #4
1
1000000000
Output #4
Yes
题目信息
题号
abc136_c
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。