Problem:
Score : 400 points

Problem Statement

Given is a number sequence A of length N.

Find the number of integers i \left(1 \leq i \leq N\right) with the following property:

For every integer j \left(1 \leq j \leq N\right) such that i \neq j , A_j does not divide A_i.

Constraints

All values in input are integers.

1 \leq N \leq 2 \times 10^5

1 \leq A_i \leq 10^6

Input

Input is given from Standard Input in the following format:

N
A_1 A_2 \cdots A_N

Output

Print the answer.

Sample Input 1

5
24 11 8 3 16

Sample Output 1

3

The integers with the property are 2, 3, and 4.

Sample Input 2

4
5 5 5 5

Sample Output 2

0

Note that there can be multiple equal numbers.

Sample Input 3

10
33 18 45 28 8 19 89 86 2 4

Sample Output 3

5

Solution in C (GCC 9.2.1) (judge verdict: Time Limit Exceeded)

#include <stdio.h>

#define rep(i, n) for (int i = 0; i < n; i = i + 1)
#define MAX 10010
#define MAX_INT 9223372036854775807

/**
 * target について、割り切れるものが無いか探す
 * 割り切れるものがあったら 1 を返す
 * なければ 0 を返す
 * @param target: long long int
 *        割られる対象
 * @param A[]: long long int
 *        これを用いて target を割っていく
 * @param N: long long int
 *        配列Aの要素数
 * @param variable_i: long long int
 *        i !== j という条件を満たすために、呼び出し側の iteration_count をもらいたかった
 * @return short int 0 | 1
 */
short find_div(long long target, long long A[], long long N, long long variable_i) {
  short ret_val = 0; // 見つからなかった
  rep(i, N) {
    if (variable_i == i) {
      continue;
    }
    //    printf("target: %lld\n", target);
    //    printf("i: %d\n", i);
    //    printf("A[i]: %lld\n", A[i]);
    //    printf("target / A[i]: %lld\n\n", target / A[i]);
    // 余りが0ということは割り切れた
    if (target % A[i] == 0) {
      ret_val = 1;
    }
  }
  return ret_val;
}

int main() {
  long long N; // <= 2 * 10^5
  scanf("%lld", &N);

  long long A[N]; // <= 10^6
  rep(i, N) {
    scanf("%lld", A + i);
  }

  long long output = 0;
  short div_ans[1000000];
  // 2で初期化
  rep(i, N) {
    div_ans[A[i]] = 2;
  }
  // 入力の1つ目から順に見ていく
  rep(i, N) {
    // 2だったら初期値
    // なのでfind_divの結果を入れる
    if (div_ans[A[i]] == 2) {
      //      printf("A[i]: %lld\n", A[i]);
      div_ans[A[i]] = find_div(A[i], A, N, i);
    }
    if (div_ans[A[i]] == 0) {
      //      printf("A[i]: %lld\n", A[i]);
      output += 1;
    }
  }

  printf("%lld\n", output);

  return 0;
}