#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int v[N];
  for (int i = 0; i < N; i++) {
    cin >> v[i];
  }
  vector<int> quadr;
  for (int i = 0; 1; i++) {
    if (i > sqrt(INT_MAX)) {
      break;
    }
    quadr.push_back(i * i);
  }
  int dist[N];
  vector<int> minDiffs;
  int contQuadr = 0;
  for (int i = 0; i < N; i++) {
    int curr = v[i];
    int index = upper_bound(quadr.begin(), quadr.end(), curr) - quadr.begin();
    int l = abs(curr - quadr[index]);
    int r = l;
    if (index - 1 >= 0) r = abs(curr - quadr[index - 1]);
    int minDiff = min(l, r);
    if (minDiff == 0) contQuadr++;
    minDiffs.push_back(minDiff);
  }
  if (contQuadr == N / 2) {
    cout << 0;
    return 0;
  }
  if (contQuadr < N / 2) {
    int diff = N / 2 - contQuadr;
    sort(minDiffs.begin(), minDiffs.end());
    long long int res = 0;
    int i = 0;
    int cont = 0;
    while (diff > 0 && i < N) {
      if (minDiffs[i] == 0) {
        i++;
        continue;
      }
      res += minDiffs[i];
      i++;
      diff--;
    }
    cout << res;
    return 0;
  }
  if (contQuadr > N / 2) {
    long long int diff = contQuadr - N / 2;
    long long int res = 0;
    int costs[N];
    memset(costs, 0, N * sizeof(int));
    for (int i = 0; i < N; i++) {
      if (v[i] == 0) {
        costs[i] = 2;
        continue;
      }
      if (minDiffs[i] == 0) {
        costs[i] = 1;
      }
    }
    sort(costs, costs + N);
    for (int i = 0; i < N && diff > 0; i++) {
      if (costs[i] == 0) continue;
      res += costs[i];
      diff--;
    }
    cout << res;
    return 0;
  }
}
