#include <bits/stdc++.h>
using namespace std;
template <class T>
T gcd(T a, T b) {
  return (b != 0 ? gcd<T>(b, a % b) : a);
}
template <class T>
T lcm(T a, T b) {
  return (a / gcd<T>(a, b) * b);
}
template <class T>
inline bool read(T &x) {
  int c = getchar();
  int sgn = 1;
  while (~c && c < '0' || c > '9') {
    if (c == '-') sgn = -1;
    c = getchar();
  }
  for (x = 0; ~c && '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0';
  x *= sgn;
  return ~c;
}
const int INF = 2000000009;
const int MX = 200005;
const double EPS = 1e-9;
const int MOD = 1000000007;
long long a[MX];
vector<long long> sq, nsq;
int n, p, q;
long long solve1() {
  vector<long long> cost;
  for (int i = 0; i < q; i++) {
    long long t = sqrt(nsq[i]);
    cost.push_back(min(nsq[i] - t * t, (t + 1) * (t + 1) - nsq[i]));
  }
  sort(cost.begin(), cost.end());
  long long ret = 0;
  int t = (n / 2) - p;
  for (int i = 0; i < t; i++) ret += cost[i];
  return ret;
}
long long solve2() {
  long long ret = 0;
  vector<long long> cost;
  for (int i = 0; i < p; i++) {
    if (sq[i] == 0)
      cost.push_back(2LL);
    else
      cost.push_back(1LL);
  }
  sort(cost.begin(), cost.end());
  int t = (n / 2) - q;
  for (int i = 0; i < t; i++) ret += cost[i];
  return ret;
}
int main() {
  n = ({
    int a;
    read(a);
    a;
  });
  for (int i = 0; i < n; i++) {
    a[i] = ({
      long long a;
      read(a);
      a;
    });
    long long t = sqrt(a[i]);
    if (t * t == a[i])
      sq.push_back(a[i]);
    else
      nsq.push_back(a[i]);
  }
  p = (int)sq.size();
  q = (int)nsq.size();
  if (p == q) {
    printf("0\n");
    return 0;
  }
  if (q > p) {
    printf("%lld\n", solve1());
  } else {
    printf("%lld\n", solve2());
  }
  return 0;
}
