#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
long long int t[1000001];
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  int count = 0, z = 0;
  long long int a[n];
  long long int b;
  for (int i = 0; i < n; i++) {
    cin >> b;
    long long int k = sqrt(b);
    if (k * k == b) {
      a[i] = 0;
      if (b == 0)
        z++;
      else
        count++;
    } else
      a[i] = min((k + 1) * (k + 1) - b, b - k * k);
  }
  sort(a, a + n);
  long long int ans = 0, val = 0;
  if (count + z >= n / 2) {
    if (count + z - n / 2 <= count)
      cout << count + z - n / 2;
    else
      cout << (2 * (z - n / 2)) + count;
  } else {
    for (int i = 0; i < n; i++) {
      ans += a[i];
      val++;
      if (val == n / 2) break;
    }
    cout << ans;
  }
  return 0;
}
