#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  long long n;
  cin >> n;
  vector<long long> a(n);
  long long sqr = 0, notsqr = 0, zero = 0;
  vector<long long> nonsqr;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    long long tmp = sqrt(a[i]);
    if (tmp * tmp == a[i]) {
      sqr++;
      if (tmp == 0) zero++;
    } else {
      notsqr++;
      nonsqr.push_back(min((tmp + 1) * (tmp + 1) - a[i], a[i] - tmp * tmp));
    }
  }
  if (sqr == notsqr)
    cout << 0;
  else if (sqr > notsqr) {
    if (sqr - zero > (sqr - notsqr) / 2)
      cout << (sqr - notsqr) / 2;
    else
      cout << (sqr - zero) + 2 * ((sqr - notsqr) / 2 - (sqr - zero));
  } else {
    sort(nonsqr.begin(), nonsqr.end());
    long long ans = 0;
    for (long long i = 0; i < (notsqr - sqr) / 2; i++) {
      ans += nonsqr[i];
    }
    cout << ans;
  }
  return 0;
}
