Remove all elements smaller than the currently being added element ( remove useless elements )
while ( ( len ( Qi ) != 0 ) and arr [ i ] >= arr [ Qi [ - 1 ] ] ) : NEW_LINE INDENT Qi . pop ( ) NEW_LINE DEDENT