#include <bits/stdc++.h>
using namespace std;
long long num[200009];
bool square(long long n) {
  int k = (int)sqrt(n);
  if (k * k == n) return true;
  return false;
}
long long fun(long long n) {
  long long k = sqrt(n);
  return min(n - (k * k), (k + 1) * (k + 1) - n);
}
int main() {
  int n;
  cin >> n;
  vector<long long> v1, v2;
  int cnt1 = 0, cnt2 = 0;
  for (int i = 0; i < n; i++) {
    cin >> num[i];
    if (square(num[i])) {
      cnt1++;
      v1.push_back(num[i]);
    } else {
      cnt2++;
      v2.push_back(num[i]);
    }
  }
  if (cnt1 == cnt2)
    cout << 0 << endl;
  else {
    if (cnt1 > cnt2) {
      int len1 = v1.size(), tmp = 0;
      for (int i = 0; i < len1; i++) {
        if (v1[i] != 0) tmp++;
      }
      if (tmp >= (cnt1 - cnt2) / 2)
        cout << (cnt1 - cnt2) / 2 << endl;
      else
        cout << 2 * ((cnt1 - cnt2) / 2 - tmp) + tmp << endl;
    } else {
      vector<int> v3;
      int len2 = v2.size();
      for (int i = 0; i < len2; i++) {
        v3.push_back(fun(v2[i]));
      }
      sort(v3.begin(), v3.end());
      long long ans = 0;
      for (int i = 0; i < (cnt2 - cnt1) / 2; i++) ans += v3[i];
      cout << ans << endl;
    }
  }
  return 0;
}
