• + 0 comments
    # Enter your code here. Read input from STDIN. Print output to STDOUT
    from collections import deque
    for _ in range(int(input())):
        n = int(input())
        blocks = deque(map(int,input().split())) 
        top_cube = 0
        while blocks:
            left_most = blocks[0]
            right_most = blocks[-1]
            left_greater = left_most > right_most
            next_cube = left_most if left_greater else right_most
            if not top_cube or next_cube <= top_cube:
                top_cube = blocks.popleft() if left_greater else blocks.pop()
            else:
                top_cube = 0
                break
        
        print ("Yes" if top_cube else "No")