#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 0, 1, -1, -1, -1, 1, 1};
int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};
template <class T>
inline T biton(T n, T pos) {
  return n | ((T)1 << pos);
}
template <class T>
inline T bitoff(T n, T pos) {
  return n & ~((T)1 << pos);
}
template <class T>
inline T ison(T n, T pos) {
  return (bool)(n & ((T)1 << pos));
}
template <class T>
inline T gcd(T a, T b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
template <typename T>
string NumberToString(T Number) {
  ostringstream second;
  second << Number;
  return second.str();
}
inline int nxt() {
  int aaa;
  scanf("%d", &aaa);
  return aaa;
}
inline long long int lxt() {
  long long int aaa;
  scanf("%lld", &aaa);
  return aaa;
}
inline double dxt() {
  double aaa;
  scanf("%lf", &aaa);
  return aaa;
}
template <class T>
inline T bigmod(T p, T e, T m) {
  T ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p) % m;
    p = (p * p) % m;
  }
  return (T)ret;
}
int ar[200010];
vector<int> sq, nsq;
int main() {
  int n = nxt();
  for (int i = 0; i < n; i++) {
    int a = nxt();
    int s = sqrt(a);
    if (s * s == a)
      sq.push_back(a);
    else
      nsq.push_back(a);
  }
  long long int sum = 0;
  if (sq.size() < nsq.size()) {
    vector<int> lol;
    for (int i = 0; i < nsq.size(); i++) {
      int tmp = sqrt(nsq[i]);
      lol.push_back(min((tmp + 1) * (tmp + 1) - nsq[i], nsq[i] - (tmp * tmp)));
    }
    sort(lol.begin(), lol.end());
    reverse(lol.begin(), lol.end());
    int ssq = sq.size();
    int snsq = nsq.size();
    while (ssq < snsq) {
      sum += lol.back();
      lol.pop_back();
      ssq++;
      snsq--;
    }
  } else {
    vector<int> lol;
    for (int i = 0; i < sq.size(); i++) {
      if (sq[i] == 0)
        lol.push_back(2);
      else
        lol.push_back(1);
    }
    sort(lol.begin(), lol.end());
    reverse(lol.begin(), lol.end());
    int ssq = sq.size();
    int snsq = nsq.size();
    while (ssq > snsq) {
      sum += lol.back();
      lol.pop_back();
      ssq--;
      snsq++;
    }
  }
  cout << sum << endl;
  return 0;
}
