why is the solution for rainbowa giving wrong answer

x=int(raw_input())

out=[]

while x>0 :

l=[]

first=[]

flag=0

half=[]

y=int(raw_input())

l=raw_input().split()

l=list(map(int, l))

for i in range(y/2):

    first.append(l[i])

    if(l[i]==(l[i+1]-1) or l[i+1]==l[i]):

        flag=1

        #print flag

    else:

        flag=0

        #print flag

for i in range(y-1,y/2, -1):

    half.append(l[i])

#print half

#print first

#print flag

for i in range(len(half)):

    if(flag==1 and half[i]==first[i]):

        flag=1

    else:

        flag=0

x-=1

if(flag==1):

    out.append("yes")

else:

    out.append("no")

for i in out:

print i

Your solution is giving wrong answer for this testcase…

1
14
1 2 3 4 5 6 8 8 6 5 4 3 2 1

answer should be no but your solution is printing yes.