YY's new problem

Time Limit: 4000ms
Memory Limit: 65536KB
This problem will be judged on HDU. Original ID: 3833
64-bit integer IO format: %I64d      Java class name: Main

Description

Given a permutation P of 1 to N, YY wants to know whether there exists such three elements P[i1], P[i2], P[i3] that
P[i1]-P[i2]=P[i2]-P[i3], 1<=i1<i2<i3<=N.

Input

The first line is T(T<=60), representing the total test cases.
Each test case comes two lines, the former one is N, 3<=N<=10000, the latter is a permutation of 1 to N.

Output

For each test case, just output 'Y' if such i1, i2, i3 can be found, else 'N'.

Sample Input

2
3
1 3 2
4
3 2 4 1

Sample Output

N
Y

Source

Language: 
Theme: 
Share Code? 

Powered by NB231 | Current Style: .