#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5, INF = 1e9 + 7;
long long i, j, n, m, ans;
long long a[N], b[N], d[N];
string st;
pair<int, int> p[N];
int main() {
  ios_base::sync_with_stdio(0);
  long long k;
  cin >> n;
  for (i = 1; i <= n; i++) cin >> a[i];
  for (i = 1; i <= n; i++) {
    int t = sqrt(a[i]);
    d[i] = min(a[i] - t * t, (t + 1) * (t + 1) - a[i]);
    p[i] = make_pair(d[i], a[i]);
  }
  sort(p + 1, p + n + 1);
  for (i = 1; i <= n / 2; i++) {
    ans += p[i].first;
  }
  for (i = n / 2 + 1; i <= n; i++) {
    if (p[i].first == 0) {
      if (p[i].second > 0)
        ans++;
      else
        ans += 2;
    }
  }
  cout << ans;
}
