AE. Kangaroo Party
题号:NC224168
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

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.

输出描述:

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.
示例1

输入

复制
5
0
3
-3
10
11

输出

复制
19