Very easy

Execution time limit is 1 second

Runtime memory usage limit is 128 megabytes

In older games one can run into the next situation. The hero jumps along the platforms that hang in the air. He must move himself from one side of the screen to the other. When the hero jumps from one platform to the neighboring, he spends $∣y_{2}−y_{1}∣_{2}$ energy, where $y_{1}$ and $y_{2}$ are the heights where these platforms hang. The hero can make a super jump that allows him to skip one platform, but it takes him $3⋅∣y_{3}−y_{1}∣_{2}$ energy.

You are given the heights of the platforms in order from the left side to the right. Find the minimum amount of energy to get from the $1$-st (start) platform to the $n$-th (last).

The first line contains the number of platforms $n(2≤n≤10_{5})$. The second line contains $n$ integers — the heights of the platforms. Their absolute values are not grater than $4000$ by absolute value.

Print one integer — the minimum amount of energy.

Input #1

Answer #1