A group of kangaroos live in houses on the number line. They all want to watch the Kangaroo Bowl!
Because not all of the kangaroos can fit a single house, they will designate two kangaroos to each host a party at their house. All other kangaroos will choose to go to the house that is closest to them, picking arbitrarily if they are the same distance from both.
A kangaroo expends (a−b)2 units of energy to travel from location a to location b. Compute the minimum total units of energy expended if the two party house locations are chosen optimally.
The first line of input contains a single integer n (2≤n≤50), which is the number of kangaroos.
Each of the next n lines contains a single integer x (−1,000≤x≤1,000), which is the location on the number line of the house of one of the kangaroos. Each location will be distinct.
Output, on a single line, the minimum total units of energy expended by all the kangaroos, given that the party house locations are chosen optimally.