Insert elements into the MaxHeap
for i in range ( n ) : NEW_LINE INDENT q . append ( a [ i ] ) NEW_LINE DEDENT q = sorted ( q ) NEW_LINE while ( len ( q ) > 0 and k > 0 ) : NEW_LINE INDENT top = q [ - 1 ] // 2 NEW_LINE DEDENT