Why does heapsort run in $\Theta(n \log n)$ instead of $\Theta(n^2 \log n)$ time?
Let us count operations line by line. You construct the heap in linear time. Then, you execute the loop and perform a logarithmic time operation $n-1$ times. Other operations take constant time. Hence, your running time is 

$\qquad \begin{align}
&amp; n + (n-1) \log n + O(1) \\
&amp;= n + n \log n - \log n + O(1) \\
&amp;= \Theta(n \log n).
\end{align}$

In other words, as $n$ grows the $n \log n$ term dominates. That is, the cost of building the heap on line 1 is negligible compared to the cost of executing the loop.