CF2000B.Seating in a Bus

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Seating in a Bus

In Berland, a bus consists of a row of nn seats numbered from 11 to nn. Passengers are advised to always board the bus following these rules:

  • If there are no occupied seats in the bus, a passenger can sit in any free seat;
  • Otherwise, a passenger should sit in any free seat that has at least one occupied neighboring seat. In other words, a passenger can sit in a seat with index ii (1in1 \le i \le n) only if at least one of the seats with indices i1i-1 or i+1i+1 is occupied.

Today, nn passengers boarded the bus. The array aa chronologically records the seat numbers they occupied. That is, a1a_1 contains the seat number where the first passenger sat, a2a_2 — the seat number where the second passenger sat, and so on.

You know the contents of the array aa. Determine whether all passengers followed the recommendations.

For example, if n=5n = 5, and aa = [5,4,2,1,35, 4, 2, 1, 3], then the recommendations were not followed, as the 33-rd passenger sat in seat number 22, while the neighboring seats with numbers 11 and 33 were free.

Input

The first line of input contains a single integer tt (1t1041 \le t \le 10^4) — the number of test cases.

The following describes the input test cases.

The first line of each test case contains exactly one integer nn (1n21051 \le n \le 2 \cdot 10^5) — the number of seats in the bus and the number of passengers who boarded the bus.

The second line of each test case contains nn distinct integers aia_i (1ain1 \le a_i \le n) — the seats that the passengers occupied in chronological order.

It is guaranteed that the sum of nn values across all test cases does not exceed 21052 \cdot 10^5, and that no passenger sits in an already occupied seat.

Output

For each test case, output on a separate line:

  • "YES", if all passengers followed the recommendations;
  • "NO" otherwise.

You may output the answer in any case (for example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as a positive answer).

Note

The first test case is explained in the problem statement.

Samples

4
5
5 4 2 1 3
3
2 3 1
4
2 3 1 4
5
1 2 3 5 4
NO
YES
YES
NO

在线编程 IDE

建议全屏模式获得最佳体验