Flower Pots FLOWERPO

All submissions for this problem are available.<h3>Read problems statements in mandarin chinese and russian.</h3>

The Chef wants to celebrate Independence Day with fireworks. He's particularly fond of Flower Pot crackers (or Fountain fireworks) which spew out fire around them:

He's decided that he wants a row of N of these crackers. He has decided where exactly each of them will be placed. In particular, we can say that the crackers will be on a line with coordinates A1, A2, ..., AN.

These crackers come in many strengths. For any integer S ≥ 0, unlimited number of crackers of strength S are available for sale at the shop. The larger the strength of a cracker, the higher and wider it will spew fire. In particular, a cracker whose strength is s, and which is placed at coordinate X will spew fire everywhere in the interval [X - S, X + S], both end points inclusive. The cost of a cracker of strength S is S2.

Chef wants to decide what the strengths of each of the N crackers should be. He wants to light up only one of the N crackers, the C-th one, which is as coordinate AC. The other N - 1 crackers should light up automatically. That is, suppose the cracker at AC has a strength of SC, then it will light up any unlit cracker in the interval [AC - SC, AC + SC]. And these should then explode and light up more crackers, etc. This should continue until all the crackers are lit. Also, each cracker, once lit, takes 1 second to explode. Once it explodes, it instantaneously lights up all the unlit crackers in its interval. And Chef wants all the crackers to be lit up (not necessarily explode) within B seconds after he has lit AC. That is, if a cracker is lit up B seconds after he has lit AC, even though it has not exploded, Chef is happy with it, and it is valid.

Find out the minimum amount Chef has to spend in buying the crackers so as to achieve his goals.

Input

Output

Constraints

Subtasks

Example

Input:
1
5 2 4
2 4 10 15 18

Output:
89

Explanation

One optimal way is to choose the strengths of the crackers as (0, 0, 8, 5, 0). That is, the leftmost cracker has strength 0, the next has 0, the next has 8, etc. Now, Chef lights up the 4-th cracker.

After 1 second, it explodes and it lights up all the unlit crackers in its interval. Because its strength is 5, its interval would be [15 - 5, 15 + 5] = [10, 20]. So after 1 second, the third and fifth cracker are also lit.

After one more second (ie. 2 seconds from when Chef lit up the 4- cracker), those two explode. Because the fifth's strength is 0, it doesn't affect anything else. But the third cracker's strength is 8, and hence it lights up all unlit crackers in the interval [10 - 8, 10 + 8] = [2, 18]. Note that this includes all the crackers. Hence all the unlit crackers are lit up instantaneously, and so all the five crackers have been lit within 2 seconds of Chef lighting up the one cracker. Thus this is a valid configuration. Also note that the first and second crackers have only been lit, and they are yet to explode. But that is fine.

The total cost of this is 02 + 02 + 82 + 52 + 02 = 89. You cannot get a lower cost, and hence this is the answer.