I think with each element they are also storing the value of max element till that point for e.g if we push elements in this order 5,5,4,3,6,2
then where each tuple means (max value of element till this point, current element)
6, 2 top
6, 6
5, 3,
5, 4
5, 5
5, 5 Bottom