An up-down sequence is any sequence where the elements alternate between increasing and decreasing. Formally, a sequence
Constraints
The sum of
Subtask 1 [20%]
Subtask 2 [80%]
No additional constraints.
Input Specification
The first line contains an integer
The first line of each test case contains a single integer
The second line of each test case contains
Output Specification
For each test case, output a single line containing YES
if it is possible to make it an up-down sequence or NO
otherwise.
Sample Input
4
7
1 0 2 5 3 0 2
5
3 0 1 2 3
4
1 0 0 1
3
6 6 0
Sample Output
YES
NO
YES
NO
Explanation for Sample
For the first test case, one may convert the sequence to
For the third test case, one may convert the sequence to
Comments