F. Equity
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Given a sequence $$$A$$$ consisting of $$$N$$$ integers.

In one operation, you can select a contiguous subsequence $$$A_i A_{i+1} \dots A_j$$$ ($$$i \le j$$$) that consists of the same element and increase all its elements by $$$1$$$. Your task is to equalize all elements of the sequence with the minimum number of operations.

Input

The first line contains the length of the sequence $$$N$$$ ($$$1 \le N \le 10^5$$$).

The second line contains the elements of the sequence $$$A$$$ ($$$0 \le A_i \le 10^9$$$).

Output

Output the minimum number of operations required to equalize all elements of the sequence.

Example
Input
4
3 1 2 4
Output
3
Note

Consider the example for the problem:

In the first operation, we increase the second element, resulting in $$$(3; 2; 2; 4)$$$. In the second operation, we increase the elements from the second to the third, resulting in $$$(3; 3; 3; 4)$$$. In the third operation, we increase the elements from the first to the third, resulting in $$$(4; 4; 4; 4)$$$.