The bar that flushes the stack.
transcript
Bars of height one, two and three. The best rectangle has area four. Your loop says zero. Why does it miss?
Each bar is taller than the last. The stack only pops lower bars. Nothing is lower, so nothing pops. The area is measured at a pop. No pop means no area.
Add a bar of height zero at the end. It is lower than every bar. It pops the three. Width one, area three. It pops the two. Width two, area four. It pops the one. Width three, area three. The best area is four.
Loop to n plus one. Read zero for the last step. Without it, the last bars are never measured. With it, every bar is measured once.
The sum of minimums needs it. Any problem that measures at a pop needs it. Use it when the last items must be finished.
A closing value flushes the stack. Add one value, and the stack empties itself. Full breakdown in the lecture.