t = int(input()) for _ in range(t): n = int(input()) a = list(map(int, input().split())) ans = [i for i in range(1, n+1)]*2 if a == ans: print("Yes") continue for i in range(n): if a[:i] + a[i:i+n+1][::-1] + a[i+n+1:] == ans: a = [] print("Yes") break if a != []: print("No")