T = int(input()) for _ in range(T): N = int(input()) A = list(map(int, input().split())) L = list(range(1, N + 1)) L = L + L if A == L: print("Yes") continue for i in range(N): temp = L[:i] + L[i+N:i:-1] + L[i+N:] if temp == A: print("Yes") break else: print("No")