#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
const int mod = 1e9 + 7;
const double eps = 1e-6;
const int base = 131;
const int N = 2e5 + 7;
int c0, c1, c2;
vector<int> v1, v2;
int main() {
  long long n, res = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int first;
    cin >> first;
    int t = sqrt(first * 1.0);
    if (t * t == first) {
      if (!t)
        v2.push_back(2);
      else
        v2.push_back(1);
    } else
      v1.push_back(min(abs((t + 1) * (t + 1) - first), abs(t * t - first)));
  }
  sort(v1.begin(), v1.end());
  sort(v2.begin(), v2.end());
  if (v1.size() > v2.size()) {
    int t = (v1.size() - (n / 2));
    for (int i = 0; i < t; i++) res += v1[i];
  } else if (v2.size() > v1.size()) {
    int t = (v2.size() - (n / 2));
    for (int i = 0; i < t; i++) res += v2[i];
  }
  cout << res << endl;
  return 0;
}
