#include <bits/stdc++.h>
using namespace std;
long long findDistanceToClosestPerfectSquare(long long x) {
  if (x <= 1) return 0;
  long long sqr = sqrt(x);
  long long p1 = sqr * sqr;
  long long p2 = (sqr + 1) * (sqr + 1);
  if (p1 == x) return 0;
  return min(abs(p1 - x), abs(p2 - x));
}
long long a[200001];
int main() {
  long long n;
  cin >> n;
  vector<pair<long long, long long> > v;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    v.push_back({findDistanceToClosestPerfectSquare(a[i]), i});
  }
  auto cmp = [](pair<long long, long long> &p, pair<long long, long long> &q) {
    if (p.first == q.first and p.first == 0) {
      return a[p.second] < a[q.second];
    }
    return p.first < q.first;
  };
  sort(v.begin(), v.end(), cmp);
  long long ans = 0;
  for (int i = 0; i < n / 2; i++) {
    ans += v[i].first;
  }
  for (int i = n / 2; i < n; i++) {
    if (v[i].first == 0) {
      if (a[v[i].second] == 0)
        ans += 2;
      else
        ans++;
    }
  }
  cout << ans << "\n";
  return 0;
}
