• + 0 comments

    # Enter your code here. Read input from STDIN. Print output to STDOUT from collections import deque

    t = int(input())

    for _ in range(t): n=int(input()) blocks=list(map(int,input().split()))

    dq = deque(blocks)
    
    current = float('inf')
    possible = True
    
    while dq:
        if dq[-1] >= dq[0]:
            next_block = dq.pop()
    
        else:
            next_block = dq.popleft()
    
        if next_block > current:
            possible=False
            break
    
        current = next_block
    
    print("Yes" if possible else "No")