• + 0 comments

    here is my solution and works

    T =int(input())
    pile=[]
    bandera=True
    
    for i in range (T):
        n=int(input())
        bloques=list(map(int, input().split()))
        pile.append([n,bloques])
        
    for repeticiones, bloques in pile:
        while len(bloques)>=2:
            top=max(bloques[0], bloques[-1])
            bloques.remove(top)    
            if(top >= bloques[-1]):
                bloques.pop()
                bandera=True
            else:
                bandera= False
                break
        print("Yes" if bandera else "No")