Eradication Sort

The members of the No-Weather-too-Extreme Recreational Climbing society
completed their first successful summit seven years ago to this day!

At the time, we took a picture of all the members standing together in one row.
However, the photograph looks messy, as the climbers were not standing in
order of height, and we have no way to reorder them.

We will need to cut some of the climbers out of the picture.

figure[!h]
sample.jpg
This picture of 7 (formerly 11) climbers was edited to solve Sample Input 3.

figure

An optimal solution minimises the size and number of visible gaps in the photo.
We define the cost as the sum of the squares of the lengths of gaps left
in the edited photo. For example, if two individual climbers are removed from
the photo and one pair of adjacent climbers are removed, the total cost
is .

Find the minimum possible cost you can reach by removing climbers.

Input
  itemize
    The number of people in the photo  ().
     integers representing the heights of people in the photo,  ().
  itemize

Output
  Output the minimum cost achieved by removing climbers from the photo,
  such that the remaining climbers in the photo make a non-decreasing sequence.
