Add all elements to heap
for i in range ( 1 , N + 1 , 1 ) : NEW_LINE INDENT pq . append ( i ) NEW_LINE DEDENT pq . sort ( reverse = False ) NEW_LINE cost = 0 NEW_LINE while ( len ( pq ) > 1 ) : NEW_LINE