#include <bits/stdc++.h>
using namespace std;
long long s[32000];
long long good[200005], bad[200005];
long long cnt1, cnt2;
long long ans;
void init() {
  for (long long i = 1; i < 32000; i++) s[i] = i * i;
}
int main() {
  init();
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    long long x;
    cin >> x;
    long long t = (long long)(sqrt(x));
    if (t * t == x)
      good[++cnt1] = x;
    else
      bad[++cnt2] = x;
  }
  if (cnt1 == n / 2)
    cout << "0" << endl;
  else if (cnt1 < n / 2) {
    for (int i = 1; i <= cnt2; i++) {
      long long t = (long long)(sqrt(bad[i]));
      long long t1 = t * t;
      long long t2 = (t + 1) * (t + 1);
      long long ans1 = bad[i] - t1;
      long long ans2 = t2 - bad[i];
      bad[i] = min(ans1, ans2);
    }
    sort(bad + 1, bad + 1 + cnt2);
    long long num = cnt1;
    for (int i = 1; i <= cnt2; i++) {
      if (num < n / 2) {
        num++;
        ans += bad[i];
      } else
        break;
    }
    cout << ans << endl;
  } else if (cnt1 > n / 2) {
    for (int i = 1; i <= cnt1; i++) {
      if (good[i] == 0)
        good[i] = 2;
      else
        good[i] = 1;
    }
    sort(good + 1, good + 1 + cnt1);
    long long num = cnt1;
    for (int i = 1; i <= cnt1; i++) {
      if (num > n / 2) {
        num--;
        ans += good[i];
      } else
        break;
    }
    cout << ans << endl;
  }
}
