#include <bits/stdc++.h>
using namespace std;
const long long maxn = 200003;
const long long maxk = 1003;
long long a[maxn];
long long n;
long long pile[maxn];
struct ND {
  long long idx, val, cost;
};
ND cst[maxn];
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (long long i = 0; i < n; ++i) {
    cin >> a[i];
    long long sq = sqrt(a[i]);
    long long cost1 = 0;
    if (sq * sq != a[i]) {
      cost1 = min(a[i] - sq * sq, (sq + 1) * (sq + 1) - a[i]);
    }
    cst[i].idx = i;
    cst[i].val = a[i];
    cst[i].cost = cost1;
  }
  auto comp = [](const ND& nd1, const ND& nd2) { return nd1.cost < nd2.cost; };
  long long ans = 0;
  sort(cst, cst + n, comp);
  long long until = n / 2;
  long long ii = 0;
  while (ii < n && until) {
    if (cst[ii].val == 0) {
      until--;
      pile[cst[ii].idx] = 1;
    }
    ++ii;
  }
  ii = 0;
  while (until > 0) {
    if (!pile[cst[ii].idx]) {
      pile[cst[ii].idx] = 1;
      ans += cst[ii].cost;
      --until;
    }
    ++ii;
  }
  for (long long i = 0; i < n; ++i) {
    if (pile[i] == 0) {
      if (a[i] == 0) {
        ans += 2;
        continue;
      }
      long long sq = sqrt(a[i]);
      if (sq * sq == a[i]) ans++;
    }
  }
  cout << ans << '\n';
  return 0;
}
