#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<long long> a, b;
  for (int i = 0; i < n; i++) {
    long long temp;
    cin >> temp;
    long long p = sqrt(temp);
    if (p * p == temp)
      a.push_back(temp);
    else
      b.push_back(temp);
  }
  if (a.size() > b.size()) {
    int rem = a.size() - n / 2;
    for (int i = 0; i < a.size(); i++) {
      if (a[i] == 0)
        a[i] = 2;
      else
        a[i] = 1;
    }
    sort(a.begin(), a.end());
    long long c = 0;
    for (int i = 0; i < a.size(); i++) {
      if (rem == 0) break;
      c += a[i];
      rem--;
    }
    cout << c << "\n";
  } else if (b.size() > a.size()) {
    int rem = b.size() - n / 2;
    for (int i = 0; i < b.size(); i++) {
      long long p = sqrt(b[i]);
      b[i] = min(abs(p * p - b[i]), abs((p + 1) * (p + 1) - b[i]));
    }
    sort(b.begin(), b.end());
    long long c = 0;
    for (int i = 0; i < b.size(); i++) {
      if (rem == 0) break;
      c += b[i];
      rem--;
    }
    cout << c << "\n";
  } else
    cout << "0\n";
  return 0;
}
