# Dynamic Programming - Linear

# Platforms - 3

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`

and _{1}`y`

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 _{2}**3** * |`y`

- _{3}`y`

|_{1}`^2`

energy. Symbol `^`

here indicated exponentiation.

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).

#### Input

The first line contains the number of platforms **n** (**2** ≤ **n** ≤ `10`

). The second line gives ^{5}**n** integers - the heights of the platforms, which absolute values are not grater than **4000** by absolute value.

#### Output

Print one integer - the minimum amount of energy.

4 1 2 3 30

731