Buggy python submission (verdict: Time Limit Exceeded):
import os
from collections import Counter, defaultdict

import math
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


# MOD = 998244353


def get_factors(n):
    """
    素因数分解
    :param int n:
    :rtype: list of int
    """
    if n <= 1:
        return []

    ret = []
    while n > 2 and n % 2 == 0:
        ret.append(2)
        n //= 2
    i = 3
    while i <= math.sqrt(n):
        if n % i == 0:
            ret.append(i)
            n //= i
        else:
            i += 2
    ret.append(n)
    return ret


def get_divisors(n):
    """
    n の約数をリストで返す
    :param int n:
    :rtype: list of int
    """
    ret = []
    for i in range(1, int(math.sqrt(n)) + 1):
        if n % i == 0:
            ret.append(i)
            if n // i != i:
                ret.append(n // i)
    return ret


N = int(sys.stdin.buffer.readline())
A = list(map(int, sys.stdin.buffer.readline().split()))

memo = [None] * (max(A) + 1)

S = set(A)
counts = Counter(A)
ans = 0
for a in A:
    if counts[a] >= 2:
        continue
    if memo[a] is not None:
        ans += memo[a]
        continue
    ok = True
    for d in get_divisors(a):
        if d == a:
            continue
        ok &= d not in S
        if not ok:
            break
    ans += ok
    memo[a] = ok
print(ans)

exit()
factors = []
for a in A:
    fs = get_factors(a)
    factors.append(fs)
    for f in fs:
        counts[f] += 1

ans = 0
for i, a in enumerate(A):
    fs = factors[i]
    ok = True
    for k, v in Counter(fs).items():
        ok &= counts[k] == v
    ans += ok
    print(i, a, ok)
print(ans)

# TODO: 1


Fixed submission:
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import random
import re
import string
import sys
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from functools import lru_cache, reduce
from math import gcd
from operator import add, itemgetter, mul, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N = int(sys.stdin.buffer.readline())
A = list(map(int, sys.stdin.buffer.readline().split()))

counter = Counter(A)
A.sort()

dp = [True] * (max(A) + 10)
ans = 0
for a in A:
    if not dp[a]:
        continue
    if counter[a] == 1:
        ans += dp[a]
    j = a
    while j < len(dp):
        dp[j] = False
        j += a
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import os
from collections import Counter

import math
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


# MOD = 998244353


def get_factors(n):
    """
    素因数分解
    :param int n:
    :rtype: list of int
    """
    if n <= 1:
        return []

    ret = []
    while n > 2 and n % 2 == 0:
        ret.append(2)
        n //= 2
    i = 3
    while i <= math.sqrt(n):
        if n % i == 0:
            ret.append(i)
            n //= i
        else:
            i += 2
    ret.append(n)
    return ret


def get_divisors(n):
    """
    n の約数をリストで返す
    :param int n:
    :rtype: list of int
    """
    ret = []
    for i in range(1, int(math.sqrt(n)) + 1):
        if n % i == 0:
            ret.append(i)
            if n // i != i:
                ret.append(n // i)
    return ret


N = int(sys.stdin.buffer.readline())
A = list(map(int, sys.stdin.buffer.readline().split()))

S = set(A)
counts = Counter(A)
ans=0
for a in A:
    if counts[a] >= 2:
        continue
    ok = True
    for d in get_divisors(a):
        if d == a:
            continue
        ok &= d not in S
    ans +=ok
print(ans)

exit()
factors = []
for a in A:
    fs = get_factors(a)
    factors.append(fs)
    for f in fs:
        counts[f] += 1

ans = 0
for i, a in enumerate(A):
    fs = factors[i]
    ok = True
    for k, v in Counter(fs).items():
        ok &= counts[k] == v
    ans += ok
    print(i, a, ok)
print(ans)

# TODO: 1


Fixed submission:
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import random
import re
import string
import sys
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from functools import lru_cache, reduce
from math import gcd
from operator import add, itemgetter, mul, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N = int(sys.stdin.buffer.readline())
A = list(map(int, sys.stdin.buffer.readline().split()))

counter = Counter(A)
A.sort()

dp = [True] * (max(A) + 10)
ans = 0
for a in A:
    if not dp[a]:
        continue
    if counter[a] == 1:
        ans += dp[a]
    j = a
    while j < len(dp):
        dp[j] = False
        j += a
print(ans)