Platforms - 3#806

Platforms - 3

1 second
128 megabytes
Easy

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 \cdot |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 -st (start) platform to the -th (last).

Input

The first line contains the number of platforms n~(2 \le n \le 10^5). The second line contains integers — the heights of the platforms. Their values do not exceed in absolute value.

Output

Print one integer — the minimum amount of energy.

Examples

Example

Input
3
2 4 1
Output
5

Example 1

Loading
Loading