#include <bits/stdc++.h>
using namespace std;
inline long long int gcd(long long int a, long long int b) {
  return b ? gcd(b, a % b) : a;
}
inline long long int fast_pow(long long int a, long long int b) {
  long long int res = 1;
  a %= 1000000007;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % 1000000007;
    a = a * a % 1000000007;
  }
  return res;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  vector<int> squares;
  for (int i = 0; i * i <= 1000000000; i++) squares.push_back(i * i);
  squares.push_back(squares.size() * squares.size());
  int n, ann = 0, borya = 0;
  cin >> n;
  vector<int> arr(n);
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    if (binary_search((squares).begin(), (squares).end(), arr[i]))
      ann++;
    else
      borya++;
  }
  if (ann == borya) {
    cout << "0\n";
  } else if (ann > borya) {
    long long int ans = 0;
    vector<int> distance;
    for (int i = 0; i < n; i++) {
      if (arr[i] == 0) {
        distance.push_back(2);
      } else if (binary_search((squares).begin(), (squares).end(), arr[i])) {
        distance.push_back(1);
      }
    }
    sort((distance).begin(), (distance).end());
    int i = 0;
    while (ann > borya) {
      ans += distance[i];
      i++;
      ann--;
      borya++;
    }
    cout << ans << '\n';
  } else {
    long long int ans = 0;
    vector<int> distance;
    for (int i = 0; i < n; i++) {
      if (!(binary_search((squares).begin(), (squares).end(), arr[i]))) {
        vector<int>::iterator high =
            upper_bound((squares).begin(), (squares).end(), arr[i]);
        vector<int>::iterator low =
            lower_bound((squares).begin(), (squares).end(), arr[i]);
        low--;
        distance.push_back(min(abs(*low - arr[i]), abs(*high - arr[i])));
      }
    }
    sort((distance).begin(), (distance).end());
    int i = 0;
    while (ann != borya) {
      ans += distance[i];
      i++;
      ann++;
      borya--;
    }
    cout << ans << '\n';
  }
  return 0;
}
