/* package codechef; // don’t place package name! */
import java.util.;
import java.lang.;
import java.io.*;
/* Name of the class has to be “Main” only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner inp =new Scanner(System.in);
int t=inp.nextInt();
int n;
int a[]=new int[100];
int c;
while(t>0)
{
c=0;
n=inp.nextInt();
if(n>=7 && n<=100)
{
for(int i=0;i<n;i++)
{
a[i]=inp.nextInt();
if(a[i]<1 || a[i]>7)
{
c++;
break;
}
}
if(c!=0)
System.out.println("no");
else
check(a,n);
}
else
System.out.println("no");
t--;
}
}
public static void check(int a[],int n)
{
int f=0;
for(int i=0;i<(n/2)+1;i++)
{
if(a[i]!=a[n-i-1])
{
f++;
break;
}
}
if(f==0)
{
for(int i=0;i<n/2;i++)
{
if(a[i+1]-a[i]!=0 && a[i+1]-a[i]!=1)
{
f++;
break;
}
}
}
if(f==0)
System.out.println(“yes”);
else
System.out.println(“no”);
}
}
/* I think I have considered all the conditions … but still I can’t get the correct ans for this question !!
can someone help me with what mistake I did here !! */