#include <bits/stdc++.h>
using namespace std;
void splitstr(const string &s, vector<string> &v) {
  istringstream in(s);
  copy(istream_iterator<string>(in), istream_iterator<string>(),
       back_inserter(v));
}
void err(vector<string>::iterator it) {}
template <typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
  cerr << *it << " = " << a << '\n';
  err(++it, args...);
}
struct point {
  int x, y;
  double len() { return sqrt(x * x + y * y); }
  double angel() { return atan2(y, x); }
  point operator+(const point &o) { return {x + o.x, y + o.y}; }
  point operator*(const int d) { return {x * d, y * d}; }
  int operator*(const point &o) { return x * o.x + y * o.y; }
  int operator^(const point &o) { return x * o.y - y * o.x; }
};
const int maxn = (2e6) + 100;
const long long INF = (1e9) + 7;
const long double EPS = 1e-8;
long long a[maxn];
bool was[maxn];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  int cnt = 0;
  int zero = 0;
  for (int i = 0; i < (int)n; i++) {
    cin >> a[i];
    long long q = sqrt(a[i]);
    if (q * q == a[i]) {
      was[i] = 1;
      cnt++;
    }
    if (a[i] == 0) {
      zero++;
    }
  }
  if (cnt == n / 2) {
    cout << 0;
    return 0;
  }
  if (cnt > n / 2) {
    int res = cnt - n / 2;
    if (zero > n / 2) {
      res += zero - n / 2;
    }
    cout << res;
    return 0;
  }
  if (cnt < n / 2) {
    vector<long long> ans;
    for (int i = 0; i < (int)n; i++) {
      if (!was[i]) {
        long long q = sqrt(a[i]);
        long long w = q * q;
        q++;
        long long r = q * q;
        long long res = min(a[i] - w, r - a[i]);
        ans.push_back(res);
      }
    }
    sort(ans.begin(), ans.end());
    long long ss = 0;
    for (int i = 0; i < (int)n / 2 - cnt; i++) {
      ss += ans[i];
    }
    cout << ss;
    return 0;
  }
  return 0;
}
