B - Exit Order Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 200 点

問題文

ある映画館には 1 から N までの番号が付いた N 個の座席があり、各座席には客が一人ずつ座っています。
この映画館では混雑対策として以下のルールに従って客が退場することになっています。

  • 座っている座席の番号が小さい順に、客を 10 人ずつのグループに分ける。
  • 座席番号が小さい客からなるグループから順に退場する。ただし、同じグループ内の客の退場順は自由である。

最後のグループの客の人数は 10 人未満にもなり得ることに注意してください。

i 番目に退場したのは座席 P_i に座っていた客でした。
N 人の客がルールに従って退場したかどうかを判定してください。

制約

  • 10 \leq N \leq 100
  • (P_1,P_2,\dots,P_N) は (1,2,\dots,N) の順列
  • 入力される値はすべて整数

入力

入力は以下の形式で標準入力から与えられる。

N  
P_1 P_2 \ldots P_N  

出力

N 人の客がルールに従って退場したならば Yes を、そうでないならば No を 1 行で出力せよ。


入力例 1

25
1 6 5 7 8 10 2 4 3 9 15 17 12 11 19 20 18 13 14 16 21 23 24 22 25

出力例 1

Yes

25 人の客は座席番号が 1 \sim 10,\; 11 \sim 20,\;21 \sim 25 の 3 つのグループに分けられます。
まず、1 つ目のグループに属する座席番号 1 \sim 10 の客 10 人が退場します。
次に、2 つ目のグループに属する座席番号 11 \sim 20 の客 10 人が退場します。
最後に、3 つ目のグループに属する座席番号 21 \sim 25 の客 5 人が退場します。
したがって、25 人の客はルールに従って退場しています。


入力例 2

11
11 10 7 2 1 5 6 4 8 9 3

出力例 2

No

Score : 200 points

Problem Statement

There is a movie theater with N seats numbered 1 through N, and one customer is sitting in each seat.
As a measure against congestion, this theater has customers leave according to the following rule.

  • Divide the customers into groups of 10 people each, in increasing order of the seat number they are sitting in.
  • The groups leave in order, starting from the group consisting of customers with the smallest seat numbers. Customers within the same group may leave in any order.

Here, the last group may have fewer than 10 customers.

The customer who left i-th was the one sitting in seat P_i.
Determine whether the N customers left according to the rule.

Constraints

  • 10 \leq N \leq 100
  • (P_1,P_2,\dots,P_N) is a permutation of (1,2,\dots,N).
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

N  
P_1 P_2 \ldots P_N  

Output

Output Yes if the N customers left according to the rule, and No otherwise, in one line.


Sample Input 1

25
1 6 5 7 8 10 2 4 3 9 15 17 12 11 19 20 18 13 14 16 21 23 24 22 25

Sample Output 1

Yes

The 25 customers were divided into three groups, with seat numbers 1 to 10, 11 to 20, and 21 to 25.
First, the 10 customers in the first group, with seat numbers 1 to 10, left.
Next, the 10 customers in the second group, with seat numbers 11 to 20, left.
Finally, the 5 customers in the third group, with seat numbers 21 to 25, left.
Thus, the 25 customers left according to the rule.


Sample Input 2

11
11 10 7 2 1 5 6 4 8 9 3

Sample Output 2

No