All that is needed to restore the max-heap property, however, is one call to MAX-HEAPIFY(A, 1), which leaves a max-heap in A[1 ‥(n - 1)]. The heapsort algorithm then repeats this process for the max-heap of size n - 1 down to a heap of size 2. HEAPSORT(A)