getting Wrong Answer Chef And Rainbow Array ?

import java.util.Scanner;
class RAINBOW {
public static void main(String [] args)
{
int i=0;
int j=0;
int k=0;
int p=0;
int q=0;
Scanner sc =new Scanner(System.in);
int T =sc.nextInt();
for(k=0;k<T; k++)
{
int N=sc.nextInt();
int [] a=new int[N];
for(j=0;j<N;j++)
{
a[j]=sc.nextInt();
}
q=N;
for(i=0;i<N/2;i++)
{
if(a[i]==a[q-1] && ((a[i+1]-a[i]==1) || a[i+1]-a[i]==0) )
{
p++;
q–;
}
}
if(p==N/2)
{
System.out.println(“yes”);
}
else
{
System.out.println(“no”);
}
p=0;
q=0;
i=0;
j=0;
}
}
}

Your code is giving incorrect output for the following test cases:

10

1 2 3 4 5 5 4 3 2 1

12

1 2 3 4 5 6 6 5 4 3 2 1

Note: You also need to check that each element from 1 to 7 are present in the array.

You can refer to my code.