Mathematical platforms#5850

Mathematical platforms

1 second
128 megabytes
Easy

In older games, which have 2D graphics, one can run into the next situation. The hero jumps along the platforms or islands that hang in the air. He must move himself from one side of the screen to the other. The hero can jump from any platform number to any platform number , spending (i - k) * (i - k) * (y_i - y_k) * (y_i - y_k) energy, where y_i and y_k are the heights where these platforms hang. Obviously energy should be spent frugally.

You are given the heights of the platforms in order from the left side to the right. Can you 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~(1 \le n \le 4000). The second line gives integers — the heights of the platforms, whose absolute values are not greater than .

Output

Print the single integer which is the minimum amount of energy to get from the -st platform to the -th.

Examples

Example 1

Loading
Loading