This seems like a very good problem unfortunately my mind has been unable to make much progress. Therefore hints would be very appreciated :D. Here is the problem:
Today, we have a very interesting problem for you. G...
I think he means that the leaves are sorted in the order of the array.
Having leaves representing values, rather than the indices makes the complexity lesser