시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB83675681.159%

문제

We call a permutation p0, p1, ... , pn-1 of integers 0, 1, ... , n-1 anti-arithmetic, when there are no three-term arithmetic series in this permutation, i.e. there are no such three indices i < j < k, that integers pi, pj, pk make an arithmetic series. For example, the series of integers 3, 1, 0, 4, 2 is an anti-arithmetic permutation of integers 0, 1, 2, 3, 4. The series 0, 5, 4, 3, 1, 2 is not an antiarithmetic permutation, because its first, fifth and sixth term: 0, 1, 2 form an arithmetic series (as well as its second, fourth and fifth term: 5, 3, 1 and second third and fourth term: 5, 4, 3 form arithmetic series). Given a permutation of length n determine whether the given permutation is anti-arithmetic or not.

입력

Input starts with an integer T, the number of test cases.

Each test case consists of two lines. First line contains an integer n. Next line contains n integers separated by a single space. These n integers denotes a permutation of 0, 1, .., n-1. n is between 3 and 50 inclusive.

출력

For each test case, the output contains a line in the format Case #x: M, where x is the case number (starting from 1) and M is “YES” when the given permutation is anti-arithmetic or “NO” otherwise. Quotes are for clarity only. 

예제 입력 1

12
4
3 1 0 2
9
0 8 4 6 2 3 7 5 1
7
1 5 3 2 6 4 0
6
3 2 5 1 4 0
10
0 8 4 2 6 9 1 5 3 7
6
3 1 5 2 4 0
3
1 0 2
3
2 0 1
5
0 4 2 1 3
7
1 5 3 0 4 2 6
6
2 0 4 5 1 3
10
4 3 1 6 9 2 5 8 0 7

예제 출력 1

Case #1: YES
Case #2: YES
Case #3: YES
Case #4: NO
Case #5: YES
Case #6: YES
Case #7: YES
Case #8: YES
Case #9: YES
Case #10: YES
Case #11: YES
Case #12: NO