KURUK14 - GENIE SEQUENCE

A Genie Sequence is a sequence in which every element indicates the number of elements present before or after it. Given an array of numbers, find whether you can form a Genie sequence or not.

Input

First line contains a single integer T, the number of test cases. It is followed by T cases each of which contains two lines. First line of each test case contains a single integer N. The next line contains N integers separated by a single space.

Output

For each test case output a single line containing "YES" (without quotes) if it is possible to form a genie sequence or "NO" (without quotes) if it is not possible.

Constraints

1 <= T <= 20

2 <= N <= 1000

1 <= ai <= 1000

Example

Input:
1
4
1 3 3 2

Output:
YES

Explanation for the test case:

The Genie sequence is {3, 1, 2, 3}. The first element '3' in the sequence indicates that three numbers are after it, the 2nd element '1' indicates that one number if before it, the 3rd element '2' indicates that two elements are before it and the last element indicates that three elements are before it. So the answer is YES.


Added by:785227
Date:2014-01-31
Time limit:0.100s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:C CSHARP C++ 4.3.2 CPP C99 JAVA PERL PYTHON PYTHON3
Resource:Kurukshetra Onsite Programming Contest

hide comments
2015-07-01 08:30:08 kp
small mistakes count >:(, easy :P
2015-03-12 16:50:30 Bala Vignesh [Inactive]
sweet!
2015-03-08 09:02:41 Piyush Kumar
Can anybody provide some tricky test cases ?
2015-01-24 21:13:42 Daksh
AC in one go easy1 :)
2014-12-20 11:37:49 :.Mohib.:
Easy....:)
2014-10-17 17:58:31 Aditya Joshi
One pass O(n) algorithm fails time limit with Java. Had to use C++ to get an AC. Time limit is too strict for Java.
2014-09-26 22:02:29 KAI
took some time but ac in 1 go :)
2014-08-22 16:25:37 a7b
Can't find error in my solution but is giving wrong answer
<snip>

Last edit: 2023-04-28 23:12:05
2014-08-06 22:08:46 WA
easy if you get the trick
2014-07-03 14:17:09 P_Quantum
easy!!
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.