• + 0 comments
    from collections import deque
    
    for _ in range(int(input())):
        _ = input()
        d = deque(list(map(int, input().split())))
        lst = []
        if d[0] <= d[-1]:
            lst.append(d.pop())
        else:
            lst.append(d.popleft())
        while len(d) > 0:
            if d[0] <= d[-1] and d[-1] <= lst[-1]:
                lst.append(d.pop())
                continue
            elif d[0] > d[-1] and d[0] <= lst[-1]:
                lst.append(d.popleft())
                continue
            else:
                break
    
        print("Yes" if len(d) == 0 else "No")