Best Time to Buy and Sell Stock 2#11613

Best Time to Buy and Sell Stock 2

1 second
128 megabytes
Easy

You are given an array of prices, where prices_i contains the price of a stock on the -th day.

Each day, you can decide whether to buy and/or sell stocks. At any given time, you can own at most one stock.

Find the maximum profit that can be obtained.

Input

The first line contains the size n~(n \le 10^5) of the price array. The second line contains the price array - integers, each not exceeding 10^4.

Output

Print the maximum profit that can be obtained. If it is impossible to obtain a profit, output .

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading