Your algorithms have become so good at predicting the market that now you know what the share price of Wooden Orange Toothpicks Inc. (WOT) will be for the next number of days.
Each day, you can either buy one share of WOT, sell any number of shares of WOT that you own, or not make any transaction at all. What is the maximum profit you can obtain with the optimum trading strategy?
The first line contains the number of predicted prices for WOT. The next line contains integers , each is a predicted stock price on the -th day.
Print the maximum profit that can be obtained in the market.