why i am getting wrong answer in ranbow array problem?

#include<stdio.h>
int main(void)
{
int i,j,t,n,flag=0,*p1,*p2;
scanf("%d\n",&t);
int st[t],s=0;
for(i=1;i<=t;i++)
{
scanf("%d\n",&n);
int a[n];
for(j=0;j<n;j++)
{
scanf("%d",&a[j]);
}
p1=a;
p2=a+n-1;
if(*p1!=1&&*p2!=1)
{
flag=1;
}
while(p1<p2)
{
if(*p1!=p2)
{
flag=1;
break;
}
if((
(p1+1)-p1)>1||((p2-1)-*p2)>1)
{
flag=1;
break;
}
p1++;p2–;
}
if(flag==1)
{
st[s]=flag;
}
else if(p1<p2)
{
st[s]=1;
}
else if(flag==0)
{
st[s]=flag;
}
s++;
}
for(s=0;s<t;s++)
{
if(st[s]==0)
{
printf(“yes”);
}
else
{
printf(“no”);
}
printf("\n");
}
return 0;
}

You solution in giving yes for this testcase but answer should be no

1
12
1 2 3 4 5 6 6 5 4 3 2 1
//