| Codeforces Round 1123 (Div. 2) |
|---|
| Finished |
Among the people from the city GR, there is a legend about a hill that leads to the backstage. An array $$$b$$$ consisting of $$$m$$$ integers is called a hill if there exists an index $$$k$$$ ($$$1\le k\le m$$$) such that the following conditions hold:
You are given an array $$$a$$$ consisting of $$$n$$$ distinct integers. You may perform the following operation any number of times:
Your task is to determine whether it is possible to turn array $$$a$$$ into a hill by performing the operation any number of times.
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^4$$$). The description of the test cases follows.
The first line of each test case contains an integer $$$n$$$ ($$$1\le n\le 2\cdot 10^5$$$) — the length of array $$$a$$$.
The second line of each test case contains $$$n$$$ distinct integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1\le a_i\le n$$$).
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2\cdot 10^5$$$.
For each test case, print "YES" if it is possible to make array $$$a$$$ a hill. Otherwise, print "NO".
You may print each letter in any case (lowercase or uppercase). For example, the strings "yEs", "yes", "Yes", and "YES" will be accepted as positive answers.
732 1 341 2 3 465 3 4 6 2 161 5 2 3 6 471 2 3 4 7 5 655 4 1 3 264 1 3 2 6 5
NOYESYESNONOYESNO
In the first test case, it is impossible to turn array $$$a$$$ into a hill.
In the second test case, array $$$a$$$ is already a hill.
In the third test case, you can perform the operations as follows:
| Name |
|---|


