peterverebics/CodeNet_Python_118 huggingface dataset:
N = int(input())
A = list(map(int, input().split()))

List = [0 for x in range(1000001)]
answer = 0

def main(a, List):
    if List[a] >= 1:
        List[a] = List[a] + 1
        return List
    else:
        for i in range(a, 1000001, a):
            List[i] = List[i] + 1
    return List

def Answer(A, List):
    answer = 0
    for a in A:
        if List[a] == 1:
            answer += 1
    return answer

for a in A:
    main(a, List)

print(Answer(A, List))
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    A = list(map(int, input().split()))

    ma = max(A)
    B = [True] * (ma+1)
    for a in list(set(A)):
        for i in range(a+a, ma+1, a):
            B[i] = False

    import collections
    ans = 0
    for k, v in collections.Counter(A).items():
        if B[k] and v == 1:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()
n = int(input())
arr = [int(x) for x in input().split()]
max_arr = max(arr)
mark = [0 for i in range(max_arr+1)]

for i in range(n):
    for j in range(arr[i], max_arr+1, arr[i]):
        mark[j] += 1
# print(mark)
count = 0
for i in range(n):
    if mark[arr[i]] == 1:
        count += 1
print(count)
N = int(input())
A = sorted(list(map(int, input().split())))
max = A[-1]
memo = ['Yes'] * (10**6+1)
ans = 0
 
for i, A_i in enumerate(A):
    if memo[A_i] == 'No':
        continue
    for j in range(A_i, max+1, A_i):
        memo[j] = 'No'
    if i != N-1 and A_i == A[i+1]:
        continue
    ans += 1
 
print(ans)
import sys
from collections import Counter

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
a = na()
a.sort()
cnt = Counter(a)
elem = [True]*(a[-1]+1)

for i in a:
  for j in range(i*2,a[-1]+1,i):
    elem[j] = False
ans = 0
for v in a:
  if elem[v] == True and cnt[v] == 1:
    ans += 1
    
print(ans)
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
C = Counter(A)

MAXN = max(A)
B = [False]*(MAXN+1)
for c in C.most_common():
    B[c[0]] = True
ans = 0
for i in range(MAXN + 1):
    if B[i]:
        if C[i]==1:
            ans += 1
        B[i::i] = [False]*(MAXN//i)
print(ans)
import sys
import numpy as np
#from numba import njit
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
#@njit('(i4[::1],)', cache=True)
def solve(A):
    count = np.zeros(10**6 + 10, np.int32)
    for x in A:
        if count[x] > 1:
            continue
        count[::x] += 1
    ret = 0
    for x in A:
        ret += count[x] == 1
    return ret

A = np.array(read().split(), np.int32)[1:]
 
print(solve(A))
import sys
readline=sys.stdin.readline

N = int(readline())
A = sorted(list(map(int,readline().split())))
M = A[-1]
from collections import Counter
counter = Counter(A)
dp = set()
ans = 0
for a in A:
  if a in dp:
    continue
  if counter[a] == 1:
    ans += 1
  for i in range(a * 2, M + 1, a):
    dp.add(i)
print(ans)
#!/usr/bin/env python3

N = int(input())
A = sorted(list(map(int, input().split())))

M = 10 ** 6  + 5
dp = [0]*(M)

for a in A:
    index = 1
    if dp[a] != 0:
        dp[a] = 2
        continue
    for i in range(a, M, a):
        dp[i] += 1

ret = 0
for a in A:
    if dp[a] == 1: ret +=1

print(ret)
n = int(input())
a = sorted(list(map(int, input().split())))

used = [False] * a[-1]
res = 0
for i in range(n):
    if used[a[i]-1]:
        continue
    if i == n - 1 or a[i] != a[i+1]:
        res += 1
    for j in range(a[i], a[-1]+1, a[i]):
        used[j-1] = True

print(res)
n = int(input())
a = list(map(int,input().split()))

a.sort()

max_a = a[-1]
is_available = [True] * (max_a + 1)

ans = 0

for i, x in enumerate(a[:-1]):
    if not a[i+1] == x and is_available[x]:
        ans += 1
    for b in range(x, max_a + 1, x):
        is_available[b] = False

if is_available[a[-1]]:
    ans += 1

print(ans)
N = int(input())
A = [int(i) for i in input().split()]

x = [0] * (10 ** 6 + 10)
y = [0] * (10 ** 6 + 10)
for a in A :
  x[a] = 1
  y[a] += 1
  
for i in range(10 ** 6 + 1) :
  if x[i] == 0 : continue
  j = i * 2
  while j <= 10 ** 6 :
    x[j] = 0
    j += i

ret = 0
for i in range(10 ** 6 + 1) :
  if x[i] == 1 and y[i] == 1 :
    ret += 1
    
print(ret)
n = int(input())
A = sorted(map(int, input().split()))

U = 10**6
line = [1]*(U+1)
ans = set()
depricated = set()
cnt = [0]*(U+1)
for a in A:
    cnt[a] += 1
    if cnt[a] == 2 and line[a]:
        depricated.add(a)
        continue
    if 2 < cnt[a]:
        continue
    if line[a]:
        ans.add(a)
        for p in range(2*a, U+1, a):
            line[p] = 0
print(len(ans-depricated))
N = int(input())
A = list(map(int, input().split()))

t = [True] * (10 ** 6 + 1)
d = {}
for a in A:
    d.setdefault(a, 0)
    d[a] += 1

A = sorted(set(A))
for a in A:
    if d[a] > 1:
        t[a] = False
    for i in range(a + a, 10 ** 6 + 1, a):
        t[i] = False

result = 0
for a in A:
    if t[a]:
        result += 1
print(result)
n = int(input())
a = list(map(int, input().split()))

if n==1:
    print(1)
    exit()

maxa=max(a)
dp=[0]*(maxa+100)
for num in a:
    for i in range(2,10**10):
        if num*i > (maxa+50):
            break
        dp[num*i]=1

import collections
c = collections.Counter(a)

aa=[]
for itm in c.items():
    num,cnt=itm
    if cnt==1:
        aa.append(num)

ans=0
for num in aa:
    if dp[num]==0:
        ans+=1
print(ans)
from collections import defaultdict, Counter
from bisect import bisect_right, bisect_left

N = int(input())
A = list(map(int, input().split()))
C = Counter(A)
a = sorted(C.keys())
dp = [1]*(a[-1]+1)
for x in a:
    if C[x] > 1:
        dp[x] = 0
    y = x+x
    while y <= a[-1]:
        dp[y] = 0
        y += x
ans = 0
for x in a:
    ans += dp[x]
print(ans)
M=10**6+1
_,*l=map(int,open(0).read().split())
a=[0]*M
for i in sorted(l):
  a[i]+=1
  if a[i]==1:
    for j in range(2*i,M,i): a[j]+=9
print(a.count(1))
def main():
    numbers = int(input())
    array = [int(x) for x in input().split()]
    maximum = 1000001
    counter = [0] * maximum

    for x in array:
        if counter[x] != 0:
            counter[x] = 2
            continue
        else:
            for multiple in range(x, maximum, x):
                counter[multiple] += 1
    ans = 0
    for x in array:
        if counter[x] == 1:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()
def solve(n,a):
    m = max(a)
    dp = [False]*(m+1)
    dup = []
    for ai in a:
        if dp[ai]:
            dup.append(ai)
        dp[ai] = True
    for ai in a:
        for i in range(2,m//ai+1):
            dp[ai*i] = False
    for ai in dup:
        dp[ai] = False
    return dp.count(True)




if __name__ == '__main__':
    n = int(input())
    a = list(map(int,input().split()))
    print(solve(n,a))
n = int(input())
a = list(map(int, input().split()))
a_max = max(a)
lst = [0] * (a_max + 1)
cnt = 0
for i in a:
    if lst[i] > 1:  # 配列中のカウントが2以上なら以降の処理を省略
        continue
    for j in range(a_max // i + 1):  # Aiの倍数にインクリメント(配列の上限はa[-1])
        lst[i * j] += 1
    # lst[1::i] += 1
for i in a:
    if lst[i] == 1:
        cnt += 1
print(cnt)
import numpy as np

N = int(input())
A = list(map(int,input().split()))

A = np.array(A)

A.sort()

d = {}

for a in A:
    d.setdefault(a,0)
    d[a] += 1



sieve = [True] * (A[-1] + 1)

for a in A:
    if d[a] > 1:
        sieve[a] = False
    for i in range(a + a, A[-1] + 1, a):
        sieve[i] = False

print(sum(1 for a in A if sieve[a]))
from collections import defaultdict
n = int(input())
arr = list(map(int,input().split()))
arr.sort()
maxn = 1000005
d = [0 for i in range(maxn)]
prime = [True for i in range(maxn)]
for i  in range(n):
	cur = arr[i]
	d[cur]+=1
	if prime[cur]==True and d[cur]==1:
		for j in range(2*cur,len(prime),cur):
			prime[j] = False
ans = 0
for i in arr:
	if prime[i]==True and d[i]==1:
		ans+=1
print(ans)
_,*a = map(int,open(0).read().split())
a.sort()
ans = 0
#M = 30
M = 10**6 + 1
l = [0] * (M)
ans = 0
for i in range(len(a)):
    if l[a[i]] == 0:
        l[a[i]] = 2
        ans += 1
        for x in range(a[i]*2, M, a[i]):
            l[x] = 1
    elif l[a[i]] == 2:
        ans -= 1
        l[a[i]] -= 1
print(ans)
n = int(input())
a  = list(map(int, input().split()))
a.sort()
dp = [0]*a[n-1]
ans = 0
temp2 = 0
for i in range(n):
  if temp2 == a[i]:
    ans -= 1
    temp2=0
  if dp[a[i]-1] == 0:
    ans += 1
    temp = a[i]
    temp2 = a[i]
    while temp <= a[n-1]:
      dp[temp-1] = 1
      temp = temp+a[i]
  #print(dp)    
print(ans)
N = int(input())
A = [int(i) for i in input().split()]

A.sort()

check = [0]*A[-1]

ans = 0
for i in range(N):
    elem = A[i]
    if check[elem-1]==0:
        if i < N-1:
            if elem != A[i+1]:
                ans += 1 
        if i==N-1:
            ans += 1
    
    now = elem
    while now <= A[-1]:
        check[now-1] = 1
        now += elem
        
print(ans)
n=int(input())
from collections import Counter as co
l=co(list(map(int,input().split())))
ans=len(l)
ng=set()
for k in l:
    if l[k]>=2:ng.add(k)
    for i in range(2*k,10**6+1,k):

        if i in l:
            ng.add(i)
            
            

print(ans-len(ng))
N=int(input())
A=list(map(int,input().split()))

mx=max(A)
f=[True]*(mx+1)
chk=[0]*(mx+1)

for a in A:
    chk[a]+=1

for a in A:
    cnt=2
    while a*cnt<=mx:
        f[a*cnt]=False
        cnt+=1
ans=0
for a in A:
    if f[a]==True and chk[a]<=1:
        ans+=1
print(ans)
N=int(input())
A=list(map(int,input().split()))

LIST=[0]*(10**6+1)

for a in A:
    LIST[a]+=1
ANS=0

for i in range(10**6+1):
    if LIST[i]==1:
        ANS+=1
    if LIST[i]!=0:
        for j in range(2*i,10**6+1,i):
            if LIST[j]!=0:
                LIST[j]+=1
print(ANS)
n=int(input())
a=list(map(int,input().split()))

x=[0]*(10**6+1)
for i in a:
    x[i]+=1


for i in range(10**6+1):
    if x[i]>=1:
        j=2
        while i*j<=10**6:
            x[i*j]=0
            j+=1
print(x.count(1))
from collections import defaultdict
n=int(input())
A=sorted((map(int,input().split())))
maxA=max(A)
L=[0]*(maxA+1)
AD=defaultdict(int)
for a in A:
	L[a]=1
	AD[a]+=1
for a in A:
	if AD[a]>=2:
		L[a]=0
	for i in range(2*a,maxA+1,a):
		L[i]=0
print(sum(L))
import sys

def solve(a,n):
    m = a[-1]+1
    ava = [0]*m
    for rep in a:
        ava[rep] += 1
        if ava[rep]:
            for i in range(2*rep,m,rep):
                ava[i] += 2
    return ava.count(1)
 
if __name__=='__main__':
    n = int(sys.stdin.readline().rstrip())
    a = list(map(int,sys.stdin.readline().rstrip().split()))
    a.sort()
    print(solve(a,n))
N = int(input())
*A,=map(int,input().split())
A = sorted(A)

if N == 1:
  print(1)
  exit()

flag = [0]*(10**6+5)
for i in range(N):
  flag[A[i]] = 1

for i in range(N):
  if flag[A[i]] == 0:
    continue
  if i>0 and A[i]==A[i-1]:
    flag[A[i]] = 0
    continue
  for num in range(A[i]*2,A[-1]+1,A[i]):
    flag[num] = 0
  
print(sum(flag))
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
c=Counter(a)
s=list(set(a))
p=[True]*(10**6+1)

for x in s:
    t=x*2
    while t<=10**6:
        p[t]=False
        t+=x
ans=0
for x in a:
    if c[x]==1 and p[x]==True:
        ans+=1
print(ans)
d = [0] * (10**6 + 1)
n = int(input())
for a in map(int, input().split()):
    d[a] += 1
ans = 0
for i in range(1, 10**6 + 1):
    if d[i] == 1:
        ans += 1
    if d[i] > 0:
        for j in range(i, 10**6 + 1, i):
            d[j] = 0
print(ans)
c=[0]*8**7
for a in[*open(0)][1].split():c[int(a)]+=1
i=r=0
for t in c:
 r+=t==1
 if t:c[::i]=[0]*-(-8**7//i)
 i+=1
print(r)
N = int(input())
A = list(map(int, input().split()))


mx = max(A)
x = [0] * (mx + 1) # len(x)
for i in A:
    x[i] += 1
for i in range(1, mx + 1):
    if x[i] != 0:
        for j in range(2 * i, mx + 1, i):
            x[j] = 0
    if x[i] > 1:
        x[i] = 0
print(sum(x))
import sys
input = sys.stdin.readline

n = int(input())
a = [int(x) for x in input().split()]
maxval = 10 ** 6
factor_cnt = [0] * (maxval+1)
factor_cnt[0] = 2
for i in range(n):
    if factor_cnt[a[i]] > 1:
        continue
    for k in range(a[i], maxval+1, a[i]):
        factor_cnt[k] += 1

result = sum(factor_cnt[v] <= 1 for v in a)
print(result)
def main():
    n = int(input())
    a = list(map(int, input().rstrip().split(' ')))
    M = 10**6 + 5
    cnt = [0 for _ in range(M)]
            
    for ai in a:
        if cnt[ai] != 0:
            cnt[ai] = 2
            continue
        for i in range(ai, M, ai):
            cnt[i] += 1
    ans = 0
    for ai in a:
        if cnt[ai] == 1:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()
from collections import Counter
def i(): return int(input())
def l(): return list(map(int,input().split()))
N = i();A = l();A.sort();dp = [1]*(10**6+1);C = Counter(A);ans = 0
for a,b in C.items():
    if b != 1:dp[a] = 0
    elif dp[a]:ans += 1
    for j in range(a,10**6+1,a):dp[j] = 0
print(ans)
def main():
    _ = int(input())
    a = list(map(int, input().split()))
    a.sort()
    a = tuple(a)

    ans = 0
    mx = max(a) + 1
    dp = [0] * mx
    for i in a:
        if dp[i] == 2:
            continue
        else:
            for j in range(i, mx, i):
                dp[j] += 1
    for i in a:
        if dp[i] == 1:
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()
import numpy as np
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    A = [int(i) for i in input().split()]

    max_dp = max(A) + 1
    dp = np.zeros(max_dp, dtype="int32")


    for a in A:
        if dp[a] >= 2:
            continue
        dp[np.arange(a, max_dp, a)] += 2
        dp[a] -= 1

    print(np.sum(dp == 1))


if __name__ == '__main__':
    main()
N=int(input())
*A,=map(int,input().split())

A.sort()
count=[0]*(A[-1]+1)
i=0
while i<N:
    j=A[i]
    if 2<=count[j]:
        i+=1
        continue
    k=1
    while j*k<=A[-1]:
        count[j*k]+=1
        k+=1
    i+=1

print(sum(count[a]==1 for a in A))
MAX = 10**6
N = int(input())
A = list(map(int, input().split()))
B = [0] * (MAX+1)
for i in range(N):
  B[A[i]] += 1
L = [0] * (MAX+1)
for k in range(MAX+1):
  if(B[k] >= 1 and L[k] == 0):
    tmp = 2*k
    while(tmp <= MAX):
      L[tmp] = 1
      tmp += k

ans = 0
for i in range(N):
  if(B[A[i]] == 1 and L[A[i]] == 0):
    ans += 1
print(ans)
N = int(input())
A = list(map(int, input().split()))
A.sort()
check = [0] * 1000001
res = 0
for i in range(N):
    if check[A[i]]:
        continue
    if i == N-1 or A[i] != A[i+1]:
        res += 1
    for j in range(A[i], 1000001, A[i]):
        check[j] = 1
print(res)
N = int(input())
A = list(map(int, input().split()))
A.sort()
MA = max(A)
dp = [True for _ in range(MA+1)]
flag = [False for _ in range(MA+1)]

for i in range(N):
    a = A[i]
    if not flag[a]:
        flag[a] = True
        t = a*2
        while t <= MA:
            dp[t] = False
            t += a
    elif flag[a] == 1:
        dp[a] = False
res = 0
for a in A:
    if dp[a]:
        res += 1
print(res)
N = int(input())
(*A,) = map(int, input().split())
maxA = max(A)

C = {a: 0 for a in A}
for a in A:
    C[a] += 1

D = {a: 0 for a in A}
for a in A:
    if C[a] > 0:
        t = 2
        while a * t <= maxA:
            D[a * t] = 1
            t += 1

ans = 0
for a in A:
    if C[a] == 1 and D[a] == 0:
        ans += 1
print(ans)
n = int(input())
a = list(map(int, input().split()))

a = sorted(a)

dp  = [0] * (a[-1]+1)

for ai in a:
    if dp[ai]:
        dp[ai] += 1
        continue

    i = 1
    while True:
        if ai*i >= len(dp):
            break
        dp[ai*i] += 1
        i += 1

ans = 0
for ai in a:
    if dp[ai] == 1:
        ans += 1

print(ans)
from collections import Counter
n = int(input())
A = sorted(list(map(int, input().split())))
A_c = Counter(A)
A_max = A[-1]

dp = [True] * (A_max + 1)
counter = 0
for i in range(len(A) - 1):
    p = A[i]
    if dp[p] == False:
        continue
    else:
        for q in range(A_max // p + 1):
            dp[p * q] = False
        if p != A[i+1]:
            counter += 1
if dp[A_max] == True:
    counter += 1
print(counter)
N = int(input())
X = list(map(int, input().split()))

MAX = 10 ** 6 + 1
prime = [True] * MAX
counted = set()
for v in X:
    if v in counted:
        prime[v] = False
        continue
    for j in range(2 * v, MAX, v):
        prime[j] = False
    counted.add(v)

ans = 0
for v in X:
    ans += int(prime[v])
print(ans)
n = int(input())
A = list(map(int, input().split()))
maxA = max(A)
tbl = set()
dup = set()
vis = set()
for a in A:
   if a in vis:
      dup.add(a)
   else:
      vis.add(a)
   s = a
   while s < maxA:
      s += a
      tbl.add(s)

cnt = 0
for a in A:
   if a in dup:
      continue
   if a not in tbl:
      cnt += 1
print(cnt)
import sys
from collections import Counter

import numpy as np

n, *aaa = map(int, sys.stdin.buffer.read().split())
cnt = Counter(aaa)
duplicated = {x for x, c in cnt.items() if c > 1}
aaa.sort()

can = np.ones(aaa[-1] + 1, np.int8)

ans = 0
for a in aaa:
    if can[a] == 0:
        continue
    if a not in duplicated:
        ans += 1
    can[a * 2::a] = 0

print(ans)
N=input()
A=list(map(int,input().split()))
M=max(A)+1
B=[True]*M
S=set()
x=0
for i in A:
  if i not in S:
    S.add(i)
    for j in range(i*2,M,i):
      B[j]=False
  else:
    B[i]=False
for i in A:
  if B[i]==True:
    x+=1
print(x)
from sys import stdin
N = int(stdin.readline().rstrip())
data = list(map(int, stdin.readline().rstrip().split()))

m = max(data)
l = [0] * (m + 1)
count = 0

for i in data:
    tmp = 1
    j = 1
    while tmp  <=  m:
        l[i * j] += 1
        j += 1
        tmp = i * j

for i in data:
    if l[i] == 1:
        count  += 1

print(count)
n = int(input())
arr = list(map(int, input().split()))
arr = sorted(arr)
m = arr[-1]
li = [0]*(m+1)
cnt = 0
        
for i in arr:
  for j in range(i, m+1, i):
    li[j] += 1

for i in arr:
  if li[i] == 1:
    cnt += 1

print(cnt)
N = int(input())
sorted_As = sorted(map(int, input().split()))
A_max = sorted_As[N-1]

dp = [True for i in range(A_max+1)]

ans = 0
for i in range(len(sorted_As)):
    a = sorted_As[i]
    
    if not dp[a]:
        continue

    if i == len(sorted_As)-1 or a != sorted_As[i+1]:
        ans += 1

    i = 1
    while a*i <= A_max:
        dp[a*i] = False
        i += 1

print(ans)
from collections import Counter

n = int(input())
array = [int(x) for x in input().split()]
counter = Counter(array)
array = sorted(set(array))
judge = [False for x in range(1000001)]
num = set()
set_f = set()
for a in array:
    if judge[a]:continue
    tmp = a
    while tmp + a <= 1000000:
        tmp += a
        judge[tmp] = True
    # print(len(num))
    # set_f |= set(factorization(a))
    # print(factorization(a))
print(len([1 for x in array if not judge[x] and counter[x] == 1]))
n  = int(input())
li = list(map(int,input().split()))
ok = set()
ng = set()
mul = set()

ans = 0

for i in li:
    if i not in ok:
        ok.add(i)
    else:
        ng.add(i)

M = max(ok)

for i in ok:
    for j in range(2,M+1):
        if i*j > 10**6:
            break
        else:
            mul.add(i*j)

for i in ok:
    if i not in mul:
        if i not in ng:
            ans+=1

print(ans)
from decimal import Decimal
from collections import Counter

N = int(input())
A = sorted([int(_) for _ in input().split()])
max_a = max(A)
min_a = min(A)
counter_A = Counter(A)
set_A = set(A)

for a in A:
  if a not in set_A:
    continue
  
  if counter_A[a] > 1:
    set_A.remove(a)
  
  i = 2
  while True:
    num = a * i
    if num > max_a:
      break
    if num in set_A:
      set_A.remove(num)
    i += 1

print(len(set_A))
n,*a=map(int,open(0).read().split())
a.sort()
num=[True for i in range(a[-1]+1)]
for i in range(n):
  if num[a[i]]:
    for j in range(a[-1]//a[i]+1):
      if j<2:
        continue
      num[a[i]*j]=False
    if i==n-1:
      pass
    elif a[i]==a[i+1]:
      num[a[i]]=False
    else:
      pass
  else:
    continue
ans=0
for i in range(n):
  if num[a[i]]:
    ans+=1
print(ans)
import sys
import copy
from collections import deque
stdin = sys.stdin
 
mod = 10**9+7
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces
 
n = ni()
a = na()
a.sort()
a_max = max(a)

c = [0 for _ in range(1000005)]
for aa in a:
    c[aa] += 1

dp = [False for _ in range(1000005)]
cnt = 0
for ai in set(a):
    if dp[ai]:
        continue
    if c[ai]==1:
        cnt += 1
    for j in range(ai+ai, a_max+1, ai):
        dp[j] = True

print(cnt)
from collections import Counter
if __name__ == "__main__":
    # Problem D
    N = int(input())
    A = sorted(map(int, input().split(' ')))
    dp = [1]* (A[-1]+1)
    C = Counter(A)

    for i in A:
        j = i*2
        while j < A[-1]+1:
            dp[j] = 0
            j += i

    ans=0
    for i in set(A):
        if C[i] == 1 and dp[i] == 1:
            ans+=1
    print(ans)
n,*a=map(int,open(0).read().split())
m=max(a)+10
li=[0]*m
for x in a:
	li[x]+=1
ans=0
for i in range(1,m):
	if li[i]:
		if li[i]==1:
			ans+=1
		for j in range(i,m,i):
			li[j]=0
print(ans)
n=int(input())
A=list(map(int,input().split()))
A.sort()

box=[True]*(A[-1]+1)

for i in range(len(A)):
    if i<n-1 and A[i]==A[i+1]:
        box[A[i]]=False
    k=2
    while A[i]*k<len(box):
        box[A[i]*k]=False
        k+=1

ans=0
for i in A:
    if box[i]:
        ans+=1
print(ans)
N = int(input())
A = list(map(int, input().split()))
 
M = 10**6 + 1
 
cnt = [0] * M
 
for a in A:
    if cnt[a] != 0:
        cnt[a] += 1
        continue
    for b in range(a, M, a):
        cnt[b] += 1
 
ans = 0
for a in A:
    if cnt[a] == 1:ans += 1
 
print(ans)
n=int(input())
a=list(map(int,input().split()))
a.sort()
dp=[0]*(a[-1]+1)

for i in a :
    dp[i]+=1

for i in a :
    if dp[i] :
        for j in range(i*2,a[-1]+1,i) :
            dp[j]=0

print(dp.count(1))
n = int(input())
a = sorted(list(map(int,input().split())))
m = max(a)+1
c = [0]*m
for x in a:
    for i in range(x,m,x):
        if c[i]<2:c[i]+=1
ans = 0
for i in a:
    if c[i]==1:
        ans += 1
print(ans)
from sys import stdin,stdout
LI=lambda:list(map(int,input().split()))
MAP=lambda:map(int,input().split())
IN=lambda:int(input())
S=lambda:input()
import math
from collections import Counter,defaultdict

d=defaultdict(int)
m=10**6+1
sieve=[-1]*m
n=IN()
a=sorted(LI())
for i in a:
    if d[i]==0:
        d[i]+=1
        for j in range(2*i,m,i):
            sieve[j]=1
    else:
        sieve[i]=1
ans=0
for i in a:
    if sieve[i]==-1:
        ans+=1
print(ans)
from collections import Counter
n=int(input())
a=sorted(list(map(int,input().split())))
a_max=a[-1]
count=0
b=Counter(a)
count_list=[0]*(a_max)
for i in a:
  if b[i]==1:
    if count_list[i-1]==0:
      count+=1
      j=1
      while i*j<=a_max:
        count_list[i*j-1]+=1
        j+=1
  else:
    j=2
    while i*j<=a_max:
      count_list[i*j-1]+=1
      j+=1
print(count)
import sys
from collections import Counter
input = lambda: sys.stdin.readline().rstrip()

MAX = 1000001
dp = [True for _ in range(MAX)]
n = int(input())
a = list(map(int, input().split()))
cnt = Counter(a)
a = sorted(list(set(a)))
ans = 0
for v in a:
   if cnt[v] <= 1 and dp[v]:
      ans += 1
   m = v
   while m < MAX:
      dp[m] = False
      m += v
print(ans)
N = int(input())
A = list(map(int,input().split()))

top = max(A)
out = [0]*(10**6+1)

for i in range(N):
  acm = A[i]
  while acm<=top:
    out[acm] += 1
    acm += A[i]
    
count = 0
for i in range(N):
  if out[A[i]] == 1:
    count += 1
print(count)
def main():
    input()
    array = sorted(int(x) for x in input().split())
    maximum = array[-1] + 1
    counter = [0] * maximum

    for x in array:
        if counter[x] != 0:
            counter[x] = 2
            continue
        else:
            for multiple in range(x, maximum, x):
                counter[multiple] += 1
    ans = 0
    for x in array:
        if counter[x] == 1:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()
n=int(input())
a=list(map(int,input().split()))
set(a)
ans=[0]*1000005
x=1
for i in a:
    if(ans[i]!=0):
        ans[i]=2
        continue
    for j in range(i,1000005,i):
        ans[j]=ans[j]+1
cnt=0
for i in range(0,n):
    if(ans[a[i]]==1):
        cnt=cnt+1
print(cnt)