#include <bits/stdc++.h>
char ch;
bool fs;
void re(long long& x) {
  while (ch = getchar(), ch < 33)
    ;
  if (ch == '-')
    fs = 1, x = 0;
  else
    fs = 0, x = ch - 48;
  while (ch = getchar(), ch > 33) x = x * 10 + ch - 48;
  if (fs) x = -x;
}
using namespace std;
long long n, m, ans, cnt, t[200001], a[200001], b[200001], c[200001];
int main() {
  re(n);
  for (long long i = 1; i <= n; ++i) {
    re(a[i]);
    b[i] = sqrt(a[i]);
    c[i] = b[i] + 1;
    b[i] *= b[i];
    c[i] *= c[i];
    if (a[i] == b[i]) ++m;
  }
  if (m >= n / 2) {
    long long last = m - n / 2;
    for (long long i = 1; i <= n; ++i)
      if (a[i] == b[i] && a[i] != 0 && last) --last, ++ans;
    ans += last * 2;
  } else {
    for (long long i = 1; i <= n; ++i)
      if (a[i] != b[i]) t[++cnt] = min(a[i] - b[i], c[i] - a[i]);
    sort(t + 1, t + cnt + 1);
    for (long long i = 1; i <= n / 2 - m; ++i) ans += t[i];
  }
  printf("%I64d\n", ans);
}
