#include "bits/stdc++.h"
#define BIT(x, i) (1 & ((x) >> (i)))
#define MASK(x) (1LL << (x))
#define OFF(x, i) ((x) & ~(1LL << (i)))
#define ON(x, i) ((1LL << (i)) | (x))
#define CNT(x) __builtin_popcountll(x)
#define task "divgroup"
#define endl '\n'
#define F first
#define S second
#define all(v) (v).begin(), (v).end()
#define TIME (1.0 * clock() / CLOCKS_PER_SEC)
#define ll long long
#define log2(x) 63 - __builtin_clzll(x)
#define FOR(i, l, r) for(int i = (l), _r = (r); i <= _r; ++i)
#define FORD(i, l, r) for(int i = (l), _r = (r); i >= _r; --i)
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l, int r)
{
return l + rng() % (r - l + 1);
}
int const LIM = 1e7 + 7;
int const N = 1e6 + 6;
int n, a[N], par[LIM], ans, pos[LIM];
int Find(int u)
{
return par[u] == u ? u : par[u] = Find(par[u]);
}
void Union(int u, int v)
{
u = Find(u), v = Find(v);
if (u == v) return;
--ans;
par[v] = u;
}
/**
(x^2 - y^2, 2xy, x2 + y2)
(x^2 - y^2) ^ 2 + (2xy)^2 = (x^2 + y^2) ^ 2
2 * x * y <= 1e7 -> y <= sqrt(1e7 / 2)
**/
void Process()
{
ans = n;
for (ll x = 1; x <= 1e7; ++x)
for (ll y = 1; y < x and 2 * x * y <= 1e7; y++)
{
ll a = x * x - y * y;
ll b = 2 * x * y;
ll c = x * x + y * y;
if (a <= 1e7 and __gcd(a, b) == 1)
{
if (pos[a] != 0 and pos[b] != 0) Union(pos[a], pos[b]);
if (c <= 1e7)
{
if (pos[b] != 0 and pos[c] != 0) Union(pos[b], pos[c]);
if (pos[a] != 0 and pos[c] != 0) Union(pos[c], pos[a]);
}
}
}
cout << ans;
}
void Gen(void)
{
int n = rnd(3, 30);
cout << n << '\n';
for (int i = 1; i <= n; ++i) cout << rnd(5, 1e7) << ' ';
}
signed main()
{
cin.tie(NULL)->sync_with_stdio(false);
if (fopen(task".inp", "r"))
{
freopen(task".inp", "r", stdin);
freopen(task".out", "w", stdout);
}
cin >> n;
for (int i = 1; i <= n; ++i)
cin >> a[i], pos[a[i]] = i, par[i] = i;
Process();
///Gen();
cerr << '\n' << "Time collapsed: " << TIME << '\n';
return 0;
}
I2luY2x1ZGUgImJpdHMvc3RkYysrLmgiCiNkZWZpbmUgQklUKHgsIGkpICgxICYgKCh4KSA+PiAoaSkpKQojZGVmaW5lIE1BU0soeCkgKDFMTCA8PCAoeCkpCiNkZWZpbmUgT0ZGKHgsIGkpICgoeCkgJiB+KDFMTCA8PCAoaSkpKQojZGVmaW5lIE9OKHgsIGkpICgoMUxMIDw8IChpKSkgfCAoeCkpCiNkZWZpbmUgQ05UKHgpIF9fYnVpbHRpbl9wb3Bjb3VudGxsKHgpCiNkZWZpbmUgdGFzayAiZGl2Z3JvdXAiCiNkZWZpbmUgZW5kbCAnXG4nCiNkZWZpbmUgRiBmaXJzdAojZGVmaW5lIFMgc2Vjb25kCiNkZWZpbmUgYWxsKHYpICh2KS5iZWdpbigpLCAodikuZW5kKCkKI2RlZmluZSBUSU1FICgxLjAgKiBjbG9jaygpIC8gQ0xPQ0tTX1BFUl9TRUMpCiNkZWZpbmUgbGwgbG9uZyBsb25nCiNkZWZpbmUgbG9nMih4KSA2MyAtIF9fYnVpbHRpbl9jbHpsbCh4KQojZGVmaW5lIEZPUihpLCBsLCByKSBmb3IoaW50IGkgPSAobCksIF9yID0gKHIpOyBpIDw9IF9yOyArK2kpCiNkZWZpbmUgRk9SRChpLCBsLCByKSBmb3IoaW50IGkgPSAobCksIF9yID0gKHIpOyBpID49IF9yOyAtLWkpCgp1c2luZyBuYW1lc3BhY2Ugc3RkOwptdDE5OTM3IHJuZyhjaHJvbm86OnN0ZWFkeV9jbG9jazo6bm93KCkudGltZV9zaW5jZV9lcG9jaCgpLmNvdW50KCkpOwppbnQgcm5kKGludCBsLCBpbnQgcikKewogICAgcmV0dXJuIGwgKyBybmcoKSAlIChyIC0gbCArIDEpOwp9CgppbnQgY29uc3QgTElNID0gMWU3ICsgNzsKaW50IGNvbnN0IE4gPSAxZTYgKyA2OwppbnQgbiwgYVtOXSwgcGFyW0xJTV0sIGFucywgcG9zW0xJTV07CgppbnQgRmluZChpbnQgdSkKewogICAgcmV0dXJuIHBhclt1XSA9PSB1ID8gdSA6IHBhclt1XSA9IEZpbmQocGFyW3VdKTsKfQoKdm9pZCBVbmlvbihpbnQgdSwgaW50IHYpCnsKICAgIHUgPSBGaW5kKHUpLCB2ID0gRmluZCh2KTsKICAgIGlmICh1ID09IHYpIHJldHVybjsKICAgIC0tYW5zOwogICAgcGFyW3ZdID0gdTsKfQoKLyoqCgooeF4yIC0geV4yLCAyeHksIHgyICsgeTIpCih4XjIgLSB5XjIpIF4gMiArICgyeHkpXjIgPSAoeF4yICsgeV4yKSBeIDIKCjIgKiB4ICogeSA8PSAxZTcgLT4geSA8PSBzcXJ0KDFlNyAvIDIpCgoqKi8KCnZvaWQgUHJvY2VzcygpCnsKICAgIGFucyA9IG47CiAgICBmb3IgKGxsIHggPSAxOyB4IDw9IDFlNzsgKyt4KQogICAgICAgIGZvciAobGwgeSA9IDE7IHkgPCB4IGFuZCAyICogeCAqIHkgPD0gMWU3OyB5KyspCiAgICAgICAgewogICAgICAgICAgICBsbCBhID0geCAqIHggLSB5ICogeTsKICAgICAgICAgICAgbGwgYiA9IDIgKiB4ICogeTsKICAgICAgICAgICAgbGwgYyA9IHggKiB4ICsgeSAqIHk7CgogICAgICAgICAgICBpZiAoYSA8PSAxZTcgYW5kIF9fZ2NkKGEsIGIpID09IDEpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGlmIChwb3NbYV0gIT0gMCBhbmQgcG9zW2JdICE9IDApIFVuaW9uKHBvc1thXSwgcG9zW2JdKTsKICAgICAgICAgICAgICAgIGlmIChjIDw9IDFlNykKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBpZiAocG9zW2JdICE9IDAgYW5kIHBvc1tjXSAhPSAwKSBVbmlvb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