#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (1) {
    cin >> n;
    if (n == 0) break;
    int input[10000] = {0};
    int max = 0;
    for (int i = 0; i < n; i++) {
      cin >> input[i];
      if (max < input[i]) max = input[i];
    }
    int sosuu[max];
    for (int i = 0; i <= max; i++) sosuu[i] = 1;
    sosuu[0] = 0;
    sosuu[1] = 0;
    for (int i = 2; i <= max; i++) {
      int now = i;
      if (sosuu[i] == 1) {
        while (now <= max) {
          now += i;
          sosuu[now] = 0;
        }
      }
    }
    int sum = 0;
    for (int i = 0; i < n; i++) {
      sum += sosuu[input[i]];
      sosuu[input[i]] = 0;
    }
    cout << sum << endl;
  }
}
