T=int(input()) for _ in range(T): N=int(input()) A=list(map(int,input().split())) X=list(range(1,N+1)); X*=2 flag=0 for i in range(N): X[i:i+N+1]=reversed(X[i:i+N+1]) if A==X: flag=1 break X[i:i+N+1]=reversed(X[i:i+N+1]) print("Yes" if flag or A==X else "No")