#include <bits/stdc++.h>
using namespace std;
set<int> sqr;
void get_squares() {
  int i;
  for (i = 0; i * i <= 1000000000; ++i) sqr.insert(i * i);
  sqr.insert(i * i);
}
int a[200005];
int tosq[200005], tonsq[200005];
int n;
int main(int argc, char* argv[]) {
  get_squares();
  scanf("%d", &n);
  int sqcnt = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    if (sqr.count(a[i])) {
      ++sqcnt;
      tosq[i] = 0;
      tonsq[i] = (a[i] == 0 ? 2 : 1);
    } else {
      auto larger = sqr.upper_bound(a[i]);
      auto smaller = prev(larger);
      tosq[i] = min(*larger - a[i], a[i] - *smaller);
      tonsq[i] = 0;
    }
  }
  long long int ans = 0;
  if (sqcnt < n / 2) {
    vector<int> vec;
    for (int i = 0; i < n; ++i) {
      if (tosq[i]) vec.push_back(tosq[i]);
    }
    sort(vec.begin(), vec.end());
    int p = 0;
    while (sqcnt < n / 2) {
      ans += vec[p++];
      ++sqcnt;
    }
  } else if (sqcnt > n / 2) {
    vector<int> vec;
    for (int i = 0; i < n; ++i) {
      if (tonsq[i]) vec.push_back(tonsq[i]);
    }
    sort(vec.begin(), vec.end());
    int p = 0;
    while (sqcnt > n / 2) {
      ans += vec[p++];
      --sqcnt;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
