#include <bits/stdc++.h>
using namespace std;
long long modpow(long long x, long long y, long long m) {
  long long z = 1;
  while (y) {
    if (y & 1) z = (z * x) % m;
    x = (x * x) % m;
    y >>= 1;
  }
  return z;
}
int egcd(int a, int b, int& x, int& y) {
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  int x1, y1;
  int gcd = egcd(b % a, a, x1, y1);
  x = y1 - (b / a) * x1;
  y = x1;
  return gcd;
}
string z[2] = {"NO", "YES"};
long long mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  string s;
  while (t--) {
    long long i, j = 0, n, s = 0, r;
    cin >> n;
    vector<long long> a(n);
    vector<pair<long long, long long> > b;
    for (i = 0; i < n; ++i) cin >> a[i];
    sort(a.begin(), a.end());
    for (i = 0; i < n; ++i) {
      r = sqrt(a[i]);
      if (r * r == a[i]) {
        ++j;
        if (2 * j > n) {
          ++s;
          if (!r) ++s;
        }
        continue;
      }
      b.push_back(
          make_pair(min(abs(a[i] - r * r), abs(a[i] - (r + 1) * (r + 1))), i));
    }
    if (2 * j < n) sort(b.begin(), b.end());
    for (i = 0; i < b.size() && 2 * j < n; ++i, ++j) s += b[i].first;
    cout << s << "\n";
  }
  return 0;
}
