rainbow array - wrong ans

can anyone find error in this please…
I am getting correct output on my terminal but wrong ans on submission…

T= int(raw_input())
for i in range(0,T):
    n=int(raw_input())
    a=list(map(int,raw_input().split()))
    if n<7 or T>100:
        print "no"
        continue
    if n%2!=0:
        p=1
        end=((n+1)/2)-1
        a1= a[0:end]
        a2= list(reversed(a[end+1:]))
        #if a[0]!=1:
            #print "no"
            #continue
        if (a1 == a2 and a[end] == (a[end - 1] + 1)):
            for i in range(0,end):
                if((a1[i]+1==a1[i+1] or a1[i]==a1[i+1])and a1[i]<=10):
                    p=0
                    break
                else:
                    p=1
            if p==1:
                print "no"
            else:
                print "yes"
        else:
            print "no"               
    else:
        p=1
        end=(n/2)
        a1= a[0:end]
        a2= list(reversed(a[end:]))
        #if a[0]!=1:
            #print "no"
            #continue
        if (a1 == a2):
            for i in range(0,end):
                if(a1[i]+1==a1[i+1] or a1[i]==a1[i+1]):
                    p=0
                    break
                else:
                    p=1
            if p==1:
                print "no"
            else:
                print "yes"
        else:
            print "no"
        

Your code is giving wrong answer for this test case…

1
15
1 2 3 4 5 6 7 7 7 6 5 4 3 2 1

answer should be yes here… But your code is giving no.