直接穷举区间就行了- - 从[0, 16] 到[1, 17]之类的, 直接暴力一下……
/*
TASK:skidesign
LANG:C++
*/
#include <iostream>
#include <cstdio>
using namespace std;
int n, tub[101]={0},ans(0x7fffffff), st;
int main()
{
freopen("skidesign.in", "r", stdin);
freopen("skidesign.out", "w", stdout);
std::ios::sync_with_stdio(false);
cin >> n;
while (n --)
{
int tmp;
cin >> tmp;
tub[tmp] ++ ;
}
for (st = 0; !tub[st]; ++ st);
for (;st <= 84; ++ st)
{
int tmp = 0, i;
for (i = 0; i != st; ++ i) tmp += tub[i]*(st-i)*(st-i);
for (i = st + 17; i != 101; ++ i) tmp += tub[i]*(i - st -17)*(i - st -17);
ans = min(ans, tmp);
}
cout << ans << endl;
return 0;
}