#include <bits/stdc++.h>   using namespace std;   bool isSquare(long long n) {     const long long s = (long long)ceil(sqrt(n));     return (s * s) == n;   }   long long calcCostToSquare(long long n) {     if (isSquare(n)) return 0;     const auto f1 = (long long)ceil(sqrt(n));     const auto f2 = (long long)floor(sqrt(n));     return min((long long)abs(f1 * f1 - n), (long long)abs(f2 * f2 - n));   }   long long calcCostToNonSquare(long long n) {     if (n == 0) return 2;     if (isSquare(n)) return 1;     return 0;   }   int main() {     long long n;     cin >> n;     long long numSquare = 0;     multiset<long long> toMakeSquare;     multiset<long long> toMakeNonSquare;     for (long long i = 0; i < n; ++i) {       long long a;       cin >> a;       if (isSquare(a)) ++numSquare;       toMakeSquare.insert(calcCostToSquare(a));       toMakeNonSquare.insert(calcCostToNonSquare(a));     }     n /= 2;     long long result = 0;     if (numSquare < n) {       auto it = toMakeSquare.upper_bound(0);       while (numSquare < n) {         result += *it;         ++it;         ++numSquare;       }     } else {       auto it = toMakeNonSquare.upper_bound(0);       while (numSquare > n) {         result += *it;         ++it;         --numSquare;       }     }     cout << result << endl;   }   