#include<bits/stdc++.h>
using namespace std;
#define el "\n"
#define ll long long
#define ull unsigned long long
#define se second
#define fi first
#define be begin()
#define en end()
#define Faster cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
ll check(ll n)
{
ll tmp = sqrt(n);
if(tmp * tmp == n) return 1;
return 0;
}
int main()
{
Faster;
int n; cin >> n;
ll ans = 0;
vector<int> vt;
while(n--)
{
ll x; cin >> x;
if(check(x))
{
vt.push_back(x);
ans += x;
}
}
if(vt.size() != 0)
{
for(auto &x : vt) cout << x << " ";
cout << el << ans;
}
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2RlZmluZSBlbCAiXG4iCiNkZWZpbmUgbGwgbG9uZyBsb25nCiNkZWZpbmUgdWxsIHVuc2lnbmVkIGxvbmcgbG9uZwojZGVmaW5lIHNlIHNlY29uZAojZGVmaW5lIGZpIGZpcnN0CiNkZWZpbmUgYmUgYmVnaW4oKQojZGVmaW5lIGVuIGVuZCgpCiNkZWZpbmUgRmFzdGVyIGNpbi50aWUoMCk7IGNvdXQudGllKDApOyBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKDApOwpsbCBjaGVjayhsbCBuKQp7CiAgICBsbCB0bXAgPSBzcXJ0KG4pOwogICAgaWYodG1wICogdG1wID09IG4pIHJldHVybiAxOwogICAgcmV0dXJuIDA7Cn0KaW50IG1haW4oKQp7CiAgICBGYXN0ZXI7CiAgICBpbnQgbjsgY2luID4+IG47CiAgICBsbCBhbnMgPSAwOwogICAgdmVjdG9yPGludD4gdnQ7CiAgICB3aGlsZShuLS0pCiAgICB7CiAgICAgICAgbGwgeDsgY2luID4+IHg7CiAgICAgICAgaWYoY2hlY2soeCkpCiAgICAgICAgewogICAgICAgICAgICB2dC5wdXNoX2JhY2soeCk7CiAgICAgICAgICAgIGFucyArPSB4OwogICAgICAgIH0KICAgIH0KICAgIGlmKHZ0LnNpemUoKSAhPSAwKQogICAgewogICAgICAgIGZvcihhdXRvICZ4IDogdnQpIGNvdXQgPDwgeCA8PCAiICI7CiAgICAgICAgY291dCA8PCBlbCA8PCBhbnM7CiAgICB9CiAgICByZXR1cm4gMDsKfQoK