#include <bits/stdc++.h>
using namespace std;
const int N = 32 * 1000;
int p[N];
void calc() {
  for (int i = 0; i < N; i++) p[i] = i * i;
}
int getS(int x) {
  int l = 1, r = N - 5;
  while (r - l > 1) {
    int m = (r + l) / 2;
    if (p[m] <= x)
      l = m;
    else
      r = m;
  }
  return l;
}
int main() {
  calc();
  int n;
  cin >> n;
  int cntSQ = 0, cntnSQ = 0;
  vector<int> a, b;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (x == 0) {
      cntSQ++;
      a.push_back(2);
    } else {
      int pos = getS(x);
      if (p[pos] == x) {
        cntSQ++;
        a.push_back(1);
      } else {
        cntnSQ++;
        b.push_back(min(x - p[pos], p[pos + 1] - x));
      }
    }
  }
  if (cntSQ == cntnSQ)
    cout << 0;
  else if (cntSQ > cntnSQ) {
    sort(a.begin(), a.end());
    int pos = a.size() - n / 2;
    int sum = 0;
    for (int i = 0; i < pos; i++) sum += a[i];
    cout << sum;
  } else {
    sort(b.begin(), b.end());
    int pos = b.size() - n / 2;
    long long sum = 0;
    for (int i = 0; i < pos; i++) sum += b[i];
    cout << sum;
  }
}
