• + 0 comments
    from collections import deque
    
    def try_next(d):
        current = max(d[0], d[-1])
    
        for _ in range(round(len(d)+1/2)):        
            if len(d) == 0:
                return True
    
            left = d[0]
            right = d[-1]
    
            if left <= current or right <= current:
                if left >= right and left <= current:
                    current = d.popleft()
                    if len(d) == 0:
                        return True
                    left = d[0]
                
                if right <= current and right >= left:
                    current = d.pop()
            else:
                return False
    
        if len(d) == 0:
            return True
    
    
    if __name__ == '__main__':
        for _ in range(int(input())):
            size = int(input())
            l = list(map(int, input().split()))
            d = deque(l)
            print("Yes" if try_next(d) else "No")