#include <bits/stdc++.h>
using namespace std;
const int M = 400010, mod = 1000000007;
int moves(int n) {
  int sq = sqrt(n);
  int minn = 1000000011;
  for (int i = max(0, sq - 3); i <= sq + 3; i++) {
    minn = min(minn, abs(i * i - n));
  }
  return minn;
}
vector<int> a, b;
int main() {
  ios_base::sync_with_stdio(false);
  int n, i, j, k;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &k);
    if (moves(k) == 0) {
      if (k == 0)
        a.push_back(2);
      else
        a.push_back(1);
    } else {
      b.push_back(moves(k));
    }
  }
  long long ans = 0;
  if (a.size() == b.size()) {
    ans = 0;
    assert(a.size() == n / 2);
  } else if (a.size() > n / 2) {
    sort((a).begin(), (a).end());
    for (i = 0; i < a.size() - n / 2; i++) ans += a[i];
  } else {
    sort((b).begin(), (b).end());
    for (i = 0; i < b.size() - n / 2; i++) ans += b[i];
  }
  cout << ans << endl;
  return 0;
}
