#include <bits/stdc++.h>
using namespace std;
int anc[32007], a[200007], cnt[2];
vector<int> vec[2];
int main() {
  int n, flag;
  long long ans = 0;
  for (int i = 1; i < 32007; i++) {
    anc[i] = i * i;
  }
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    int j = lower_bound(anc, anc + 32007, a[i]) - anc;
    if (anc[j] == a[i]) {
      cnt[0]++;
      vec[0].push_back(a[i] == 0 ? 2 : 1);
    } else {
      cnt[1]++;
      vec[1].push_back(min(anc[j] - a[i], a[i] - anc[j - 1]));
    }
  }
  if (cnt[0] > cnt[1]) {
    flag = 0;
  } else {
    flag = 1;
  }
  sort(vec[flag].begin(), vec[flag].end());
  for (int i = 0; i < vec[flag].size() && i < abs(cnt[0] - cnt[1]) / 2; i++) {
    ans += vec[flag][i];
  }
  printf("%lld\n", ans);
  return 0;
}
