#include <bits/stdc++.h>
int a[1000000];
int f[10000001] = {0};
inline int t(int a, int b) {
  int aa = a, bb = b, t;
  if (!f[a] || !f[b]) return 0;
  while (f[a] != a) a = f[a];
  while (f[b] != b) b = f[b];
  if (a == b) return 0;
  while (f[aa] != aa) {
    t = aa;
    aa = f[aa];
    f[t] = b;
  }
  while (f[bb] != bb) {
    t = bb;
    bb = f[bb];
    f[t] = b;
  }
  f[a] = b;
  return 1;
}
int main() {
  int i, n, v, u, x, y, z, c, b, r;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    f[a[i]] = a[i];
  }
  r = n;
  for (u = 1; 2 * u * u < 10000001; u++)
    for (v = u + 1; (x = 2 * v * u) < 10000001; v += 2) {
      if ((y = v * v - u * u) >= 10000001) break;
      c = u;
      b = v;
      while (c && b) {
        if (c > b)
          c %= b;
        else
          b %= c;
      }
      if (c + b != 1) continue;
      z = v * v + u * u;
      r -= t(x, y);
      if (z < 10000001) {
        r -= t(x, z);
        r -= t(y, z);
      }
    }
  printf("%d", r);
  return 0;
}
