#include <bits/stdc++.h>
using namespace std;
long long n, i, c, d, t, ttt;
long long tmp, t1, t2;
long long arrb[200000];
long long arrc[200000];
long long sqrt(long long x) {
  if (x == 0) return 0;
  int i, j, k;
  i = 0;
  j = 40000;
  k = (i + j) / 2;
  while (i != j) {
    if ((k * k) >= x) j = k;
    if ((k * k) <= x) i = k;
    if ((k * k) == x) {
      i = k;
      j = k;
      break;
    }
    if ((j - i) <= 1) break;
    k = (i + j) / 2;
  }
  if (i * i == x) return (-i);
  if (j * j == x) return (-j);
  return (i);
}
long long tonearest(long long x) {
  if (x == 0) return 2;
  tmp = sqrt(x);
  if (tmp < 0)
    return 1;
  else {
    t1 = x - tmp * tmp;
    t2 = (tmp + 1) * (tmp + 1) - x;
    if (t1 > t2)
      return (-t2);
    else
      return (-t1);
  }
}
int main() {
  c = 0;
  d = 0;
  scanf("%I64d", &n);
  for (i = 0; i < n; i++) {
    scanf("%I64d", &ttt);
    t = tonearest(ttt);
    if (t > 0) {
      arrb[c] = t;
      c++;
    } else {
      arrc[d] = -t;
      d++;
    }
  }
  if (c > d) {
    sort(arrb, arrb + c);
    ttt = 0;
    for (i = 0; i < (c - d) / 2; i++) {
      ttt += arrb[i];
    }
  } else {
    sort(arrc, arrc + d);
    ttt = 0;
    for (i = 0; i < (d - c) / 2; i++) {
      ttt += arrc[i];
    }
  }
  printf("%I64d", ttt);
  return 0;
}
