1859: [贪心]改造skidesign

Memory Limit:128 MB Time Limit:1.000 S
Judge Style:Text Compare Creator:
Submit:13 Solved:5

Description

给出n座山的高度a[i],要求最高的山峰与最低的山峰的高度差不超过17。

将高度为a[i]的山峰改造成高度为x的山峰的代价为(a[i] – x)2

求最小的代价将这n座山改造成满足要求的。

Input

第一行一个数n

接下来n行每行一个整数a[i](0 ≤ a[i] ≤ 100),表示山峰高度。

Output

一行一个整数,最小的代价

Sample Input Copy

5
20
4
1
24
21

Sample Output Copy

18

HINT

【数据规模】

对于30%的数据,1 ≤ n ≤ 100

对于50%的数据,1 ≤ n ≤ 500

对于100%的数据,1 ≤ n ≤ 1000