t = int(input()) for _ in range(t): n = int(input()) A = list(map(int, input().split())) X = list(range(1, n+1))+list(range(1, n+1)) if A == X: print('Yes') continue flag = False for i in range(n): B = X[0:i]+list(reversed(X[i:i+n+1]))+X[i+n+1:] if A == B: flag = True break if flag: print('Yes') else: print('No')