import sys input = sys.stdin.readline T=int(input()) for tests in range(T): N=int(input()) A=list(map(int,input().split())) OK=[0]*N for i in range(1,N-1): if A[i-1]A[i]>A[i+1]: OK[i]=1 B=[] for i in range(N): if OK[i]==0: B.append(A[i]) if len(B)==5 and B[0]>B[1]: print("Yes") else: print("No")