#include <bits/stdc++.h>
using namespace std;
vector<long long> per;
vector<pair<long long, long long> > nper;
long long near(long long temp) {
  long long root = sqrt(temp);
  long long num1 = root * root;
  long long num2 = (root + 1) * (root + 1);
  return min(abs(num1 - temp), abs(num2 - temp));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, temp;
  cin >> n;
  long long cper = 0, cnper = 0;
  for (long long i = 0; i < n; i++) {
    cin >> temp;
    long long root = sqrt(temp);
    if (root * root == temp) {
      per.push_back(temp);
      cper++;
    } else {
      cnper++;
      nper.push_back(make_pair(near(temp), temp));
    }
  }
  if (cper == cnper) {
    cout << "0\n";
  } else if (cper > cnper) {
    long long ans = 0;
    sort(per.begin(), per.end());
    long long ref = per.size();
    for (long long i = ref - 1, k = 0; i >= 0; i--) {
      if (per[i] == 0)
        ans += 2;
      else
        ans++;
      k++;
      if (k == (cper - (n / 2))) break;
    }
    cout << ans << "\n";
  } else {
    long long ans = 0;
    sort(nper.begin(), nper.end());
    for (long long i = 0; i < (cnper - (n / 2)); i++) {
      ans += (nper[i].first);
    }
    cout << ans << "\n";
  }
  return 0;
}
