#include <bits/stdc++.h>
using namespace std;
long long a[200005];
vector<long long> eq, neq, ans;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    long long tmp = sqrt(a[i]);
    if (tmp * tmp == a[i]) {
      eq.push_back(a[i]);
    } else
      neq.push_back(a[i]);
  }
  long long leneq = eq.size();
  long long lenneq = neq.size();
  if (leneq > lenneq) {
    for (long long i = 0; i < leneq; i++) {
      if (eq[i] == 0)
        ans.push_back(2);
      else
        ans.push_back(1);
    }
  } else if (leneq < lenneq) {
    for (int i = 0; i < lenneq; i++) {
      long long tmp = sqrt(neq[i]);
      ans.push_back(min(neq[i] - tmp * tmp, (tmp + 1) * (tmp + 1) - neq[i]));
    }
  } else {
    puts("0");
    return 0;
  }
  sort(ans.begin(), ans.end());
  long long len = abs(leneq - lenneq) / 2;
  long long res = 0;
  for (int i = 0; i < len; i++) {
    res += ans[i];
  }
  cout << res << endl;
}
