Car Racing

Time limit1sMemory limit128 MB

Problem

A car race is held on the track shown below.

Track diagram

Only a single lane leads to the starting line, so the cars must reach the starting line lined up in increasing order of the numbers they earned in the preliminary race: $1, 2, \dots, N$. The cars arrive at the main entrance in some order, and we want to know whether they can be reordered into $1, 2, \dots, N$ using a single one-lane bypass.

Every car may only move forward, in the direction of the arrows. A car that reaches the entrance either drives straight on to the starting line or pulls into the bypass to wait. Because the bypass is a single lane and cars never move backward, cars leave the bypass in the same order they entered it (first in, first out). The bypass is long enough to hold every car in the race.

For example, suppose four cars arrive in the order $1, 3, 2, 4$. They can be lined up as $1, 2, 3, 4$ like this: car $1$ drives straight to the starting line; car $3$ pulls into the bypass and waits; car $2$ drives straight to the starting line; car $3$ leaves the bypass and reaches the starting line; finally car $4$ drives straight to the starting line.

Given the arrival order, decide whether the cars can be lined up as $1, 2, \dots, N$.

Input

The first line contains the number of test cases $T$.

Each test case consists of two lines. The first line contains an integer $N$ ($1 \le N < 100$), the number of cars in the race. The second line contains a permutation of $1, 2, \dots, N$ — the order in which the cars arrive at the entrance — with the numbers separated by single spaces.

Output

For each test case, print a single line containing YES if the cars can be lined up in increasing order $1, 2, \dots, N$, or NO otherwise.