#include <bits/stdc++.h>
using namespace std;
vector<long long> v, ans;
int n, z;
long long sum;
void fn() {
  for (int i = 0; i <= 100000; i++) v.push_back((long long)i * i);
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    if (!arr[i]) z++;
  }
  fn();
  sort(arr, arr + n);
  for (int i = 0; i < n; i++) {
    int diff1 = 1e9, diff2 = 1e9, idx1, idx2;
    idx1 = lower_bound(v.begin(), v.end(), (long long)arr[i]) - v.begin();
    idx2 = upper_bound(v.begin(), v.end(), (long long)arr[i]) - v.begin() - 1;
    diff1 = abs(v[idx1] - arr[i]);
    if (idx2 >= 0) diff2 = abs(arr[i] - v[idx2]);
    ans.push_back(min(diff1, diff2));
  }
  sort(ans.begin(), ans.end());
  for (int i = 0; i < ans.size(); i++) {
    if (i < n / 2)
      sum += (long long)ans[i];
    else if (ans[i] == 0) {
      if (z > n / 2)
        sum += (long long)2, z--;
      else
        sum++;
    }
  }
  cout << sum << endl;
  return 0;
}
