t = int(input()) for _ in range(t): n = int(input()) h = list(map(int, input().split())) l = 0 r = 0 for i in range(1, n - 1): if h[i - 1] > h[i] and h[i] < h[i + 1]: l += 1 elif h[i - 1] < h[i] and h[i] > h[i + 1]: r += 1 print("Yes" if (l == 2 and r == 1) else "No")