Hongjun is deep into the stock market these days. He has a sharp eye for the future, so the price he predicts for each day always turns out to be right. Every day he does exactly one of the following.
- Buy one share.
- Sell as many of the shares he holds as he wants.
- Do nothing.
Knowing every future price is not the same as knowing how to trade. Given the price on each day, compute the largest profit Hongjun can make.
For example, if there are 3 days and the prices are 10, 7, 6, the price only falls and the largest profit is 0. If the prices are 3, 5, 9, he buys one share on each of the first two days and sells both on the last day for a profit of 10.