• + 0 comments
    import math
    
    def main():
        t = int(input())
        for _ in range(t):
            _, blocks = int(input()), list(map(int, input().split()))
            result = True
            top = math.inf
            i, j = 0, len(blocks) - 1
    
            while i <= j and result:
                left = blocks[i]
                right = blocks[j]
                if left >= right:
                    if left <= top:
                        top=left
                        i+=1
                    else:
                        result = False
                else:
                    if right <= top:
                        top=right
                        j-=1
                    else:
                        result = False
    
            if result:
                print("Yes")
            else:
                print("No")
    
    if __name__ == "__main__":
        main()