Marcus is so excited for Christmas, that he decided to make cookie platters for Santa!
To do so, he took ovens, all of which are lined up in a row, and decided to set the oven to a temperature of degrees (all of the ovens are initially degrees).
Marcus decides to set the temperatures in a weird way. If he increases the temperature of an oven by , he must also increase the temperature of all ovens to the right by .
Similarly, if he reduces the temperature by , he must also reduce the temperature of all ovens to the right by (it is possible to set an oven to a negative temperature).
He wants to finish this task before Santa arrives, and he asks you to figure out the minimum number of steps it takes him to finish setting all ovens to the right temperature.
Input
The first line contains an integer , signifying the number of ovens.
The next line has integers , representing the temperature he wants the oven to have.
Output
Output one integer, the minimum number of steps it takes him to set each oven to the right temperature.
Sample Input
5
1 4 3 2 5
Sample Output
5
Explanation for Sample Input
Marcus initially has ovens, each at temperature . He then performs the following steps:
- Increase the temperature of the oven by (
1 1 1 1 1
) - Increase the temperature of the oven by (
1 1 1 1 4
) - Increase the temperature of the oven by (
1 4 4 4 7
) - Decrease the temperature of the oven by (
1 4 4 3 6
) - Decrease the temperature of the oven by (
1 4 3 2 5
)
Comments
Why isn't the temperature measured in Kelvin