#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
const int maxn = 200000 + 10;
int n;
struct node {
  int val;
  int c1, c2;
};
node a[maxn];
bool judge(int x) {
  int num = (int)sqrt(x);
  return num * num == x;
}
int change(int x) {
  int num = (int)sqrt(x);
  int c1 = abs(num * num - x);
  int c2 = abs((num + 1) * (num + 1) - x);
  return min(c1, c2);
}
int change2(int x) {
  int num = (int)sqrt(x);
  if (num * num == x) {
    if (x == 0) return 2;
    return 1;
  }
  return 0;
}
bool cmp1(const node &a, const node &b) { return a.c1 < b.c1; }
bool cmp2(const node &a, const node &b) { return a.c2 < b.c2; }
int main(int argc, char const *argv[]) {
  while (cin >> n) {
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      scanf("%d", &a[i].val);
      a[i].c1 = change(a[i].val);
      a[i].c2 = change2(a[i].val);
      if (judge(a[i].val)) cnt++;
    }
    long long ans = 0;
    if (cnt < n / 2) {
      int num = 0;
      sort(a, a + n, cmp1);
      for (int i = 0; i < n; i++) {
        if (judge(a[i].val)) continue;
        ans += a[i].c1;
        num++;
        if (num == n / 2 - cnt) break;
      }
    } else if (cnt > n / 2) {
      int num = 0;
      sort(a, a + n, cmp2);
      for (int i = 0; i < n; i++) {
        if (!judge(a[i].val)) continue;
        ans += a[i].c2;
        num++;
        if (num == cnt - n / 2) break;
      }
    }
    printf("%I64d\n", ans);
  }
  return 0;
}
