#include <iostream>
using namespace std;
const int N = 1010;
int a[N];
int main(){
int n; cin >> n;
for(int i = 0; i < n; i ++ ) cin >> a[i];
int res = 1e8;
for(int i = 0; i + 17 <= 100; i ++ ){
int tmp = 0, l = i, r= i + 17;
for(int j = 0; j < n; j ++ ){
if(a[j] < l) tmp += (l - a[j]) * (l - a[j]);
else if(a[j] > r) tmp += (r - a[j]) * (r - a[j]);
}
res = min(res, tmp);
}
cout << res << endl;
return 0;
}