Timer is Running

Submissions: 1308   Accuracy:


  Difficulty: Basic   Marks: 1

Vishesh, who doesn't like maths, has to certify v-shaped tracks. A track is valid if it satisfies the following conditions :
1. There must be a constant difference between the height of pillars (not zero) of a track. For eg., if the heights of first two pillars are 7 and 5, then height of 3rd pillar must be 3. As 7-5=2 & 5-3=2.
2. The height of middle pillar must be always 1.
3. Number of pillars on the left side must be equal to the number of pillars on the right side of middle pillar. And their heights must be also equal. for example: Track with pillar heights [3 2 1 2 3] is a valid track. 
Help him in finding the valid tracks.

The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case consists of two lines. First line of each test case contains an Integer N denoting number of pillars and the second line contains N space separated integers which are the heights of pillar.

Print on the new  line "Yes" if it is a valid v-shaped track. Otherwise, print "No".

1 <= T <= 100
3 <= N <= 106
1 <= H[i] <= 106


2 1 2
4 3 2 3 4


** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Arun Tyagi
Author: arun03

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.