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

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

cnt = Counter(a)
a.sort()

cand = a
ans = 0
while cand:
    p = cand[0]
    if cnt[p] == 1:
        ans += 1
    nex = []
    for num in cand:
        if num == p:
            continue
        if num % p:
            nex.append(num)
    cand = nex

print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))

a.sort()
am = a[-1]

memo = [0] * (am+1)

for ai in a:
    memo[ai] = 1

p = -1

for ai in a:
    if ai == p:
        memo[ai] = 0
        continue
    for j in range(2, am // ai + 1):
        memo[ai * j] = 0
    p = ai

print(sum(memo))

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

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

cnt = Counter(a)
a = list(set(a))
a.sort()

def eratosthenes(a):
    cand = a
    ans = 0
    while cand:
        p = cand[0]
        if cnt[p] == 1:
            ans += 1
        nex = []
        for num in cand:
            if num == p:
                continue
            if num % p:
                nex.append(num)
        cand = nex
    return ans

print(eratosthenes(a))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))

a.sort()
am = a[-1]

memo = [0] * (am+1)

for ai in a:
    memo[ai] = 1

p = -1

for ai in a:
    if ai == p:
        memo[ai] = 0
        continue
    for j in range(2, am // ai + 1):
        memo[ai * j] = 0
    p = ai

print(sum(memo))

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

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

cnt = Counter(a)
a = list(set(a))
a.sort()

def eratosthenes(a):
    cand = a
    ans = 0
    while cand:
        p = cand[0]
        if cnt[p] == 1:
            ans += 1
        nex = []
        for num in cand:
            if num == p:
                continue
            if num % p:
                nex.append(num)
        cand = nex
    return ans

print(eratosthenes(a))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))

a.sort()
am = a[-1]

memo = [0] * (am+1)

for ai in a:
    memo[ai] = 1

p = -1

for ai in a:
    if ai == p:
        memo[ai] = 0
        continue
    for j in range(2, am // ai + 1):
        memo[ai * j] = 0
    p = ai

print(sum(memo))

Buggy python submission (verdict: Runtime Error):
from collections import Counter
import math

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

dic = Counter(a)

ans = 0

memo = {}

def seachPrimeNum(N):
    max = int(np.sqrt(N))
    seachList = [i for i in range(2,N+1)]
    primeNum = []
    while seachList[0] <= max:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    return primeNum

primeNum = set(seachPrimeNum(10**6))

for ai in a:
    cnt = 0
    f = 1
    if ai not in memo:
        if ai not in primeNum:
            for i in range(1, int(math.sqrt(ai))+1):
                if ai % i == 0:
                    d = i
                    if d in dic:
                        cnt += dic[d]
                    if d == ai:
                        cnt -= 1
                    if cnt > 0:
                        f = 0
                        break
                    if i != ai // i:
                        d = ai // i
                        if d in dic:
                            cnt += dic[d]
                        if d == ai:
                            cnt -= 1
                        if cnt > 0:
                            f = 0
                            break
    else:
        f = memo[ai]
    ans += f
    memo[ai] = f

print(ans)
    

            




Fixed submission:
n = int(input())
a = list(map(int, input().split()))

a.sort()
am = a[-1]

memo = [0] * (am+1)

for ai in a:
    memo[ai] = 1

p = -1

for ai in a:
    if ai == p:
        memo[ai] = 0
        continue
    for j in range(2, am // ai + 1):
        memo[ai * j] = 0
    p = ai

print(sum(memo))

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

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

dic = Counter(a)

ans = 0

memo = {}

for ai in a:
    cnt = 0
    f = 1
    if ai not in memo:
        for i in range(1, int(math.sqrt(ai))+1):
            if ai % i == 0:
                d = i
                if d in dic:
                    cnt += dic[d]
                if d == ai:
                    cnt -= 1
                if cnt > 0:
                    f = 0
                    break
                if i != ai // i:
                    d = ai // i
                    if d in dic:
                        cnt += dic[d]
                    if d == ai:
                        cnt -= 1
                    if cnt > 0:
                        f = 0
                        break
    else:
        f = memo[ai]
    ans += f
    memo[ai] = f

print(ans)
    

            




Fixed submission:
n = int(input())
a = list(map(int, input().split()))

a.sort()
am = a[-1]

memo = [0] * (am+1)

for ai in a:
    memo[ai] = 1

p = -1

for ai in a:
    if ai == p:
        memo[ai] = 0
        continue
    for j in range(2, am // ai + 1):
        memo[ai * j] = 0
    p = ai

print(sum(memo))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

from collections import Counter

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

dic = Counter(a)

ans = 0

memo = {}

for ai in a:
    cnt = 0
    f = 1
    if ai not in memo:
        for i in range(1, int(ai**0.5)+1):
            if ai % i == 0:
                d = i
                if d in dic:
                    cnt += dic[d]
                if d == ai:
                    cnt -= 1
                if cnt > 0:
                    f = 0
                    break
                if i != ai // i:
                    d = ai // i
                    if d in dic:
                        cnt += dic[d]
                    if d == ai:
                        cnt -= 1
                    if cnt > 0:
                        f = 0
                        break
    else:
        f = memo[ai]
    ans += f
    memo[ai] = f

print(ans)
    

            




Fixed submission:
n = int(input())
a = list(map(int, input().split()))

a.sort()
am = a[-1]

memo = [0] * (am+1)

for ai in a:
    memo[ai] = 1

p = -1

for ai in a:
    if ai == p:
        memo[ai] = 0
        continue
    for j in range(2, am // ai + 1):
        memo[ai * j] = 0
    p = ai

print(sum(memo))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

from collections import Counter

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

dic = Counter(a)

ans = 0

memo = {}

for ai in a:
    cnt = 0
    f = 1
    if ai not in memo:
        for i in range(1, int(ai**0.5)+1):
            if ai % i == 0:
                d = i
                if d in dic:
                    cnt += dic[d]
                if d == ai:
                    cnt -= 1
                if cnt > 0:
                    f = 0
                    break
                if i != ai // i:
                    d = ai // i
                    if d in dic:
                        cnt += dic[d]
                    if d == ai:
                        cnt -= 1
                    if cnt > 0:
                        f = 0
                        break
    else:
        f = memo[ai]
    ans += f
    memo[ai] = f

print(ans)
    

            




Fixed submission:
n = int(input())
a = list(map(int, input().split()))

a.sort()
am = a[-1]

memo = [0] * (am+1)

for ai in a:
    memo[ai] = 1

p = -1

for ai in a:
    if ai == p:
        memo[ai] = 0
        continue
    for j in range(2, am // ai + 1):
        memo[ai * j] = 0
    p = ai

print(sum(memo))

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

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

dic = Counter(a)

ans = 0

for ai in a:
    cnt = 0
    f = 1
    for i in range(1, int(ai**0.5)+1):
        if ai % i == 0:
            d = i
            if d in dic:
                cnt += dic[d]
            if d == ai:
                cnt -= 1
            if cnt > 0:
                f = 0
                break
            if i != ai // i:
                d = ai // i
                if d in dic:
                    cnt += dic[d]
                if d == ai:
                    cnt -= 1
                if cnt > 0:
                    f = 0
                    break

    ans += f

print(ans)
    

            




Fixed submission:
n = int(input())
a = list(map(int, input().split()))

a.sort()
am = a[-1]

memo = [0] * (am+1)

for ai in a:
    memo[ai] = 1

p = -1

for ai in a:
    if ai == p:
        memo[ai] = 0
        continue
    for j in range(2, am // ai + 1):
        memo[ai * j] = 0
    p = ai

print(sum(memo))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

dic = {}
for ai in a:
    if ai not in dic:
        dic[ai] = 0
    dic[ai] += 1

ans = 0

for ai in a:
    cnt = 0
    f = 1
    for i in range(1, int(ai**0.5)+1):
        if ai % i == 0:
            d = i
            if d in dic:
                cnt += dic[d]
            if d == ai:
                cnt -= 1
            if cnt > 0:
                f = 0
                break
            if i != ai // i:
                d = ai // i
                if d in dic:
                    cnt += dic[d]
                if d == ai:
                    cnt -= 1
                if cnt > 0:
                    f = 0
                    break

    ans += f

print(ans)
    

            




Fixed submission:
n = int(input())
a = list(map(int, input().split()))

a.sort()
am = a[-1]

memo = [0] * (am+1)

for ai in a:
    memo[ai] = 1

p = -1

for ai in a:
    if ai == p:
        memo[ai] = 0
        continue
    for j in range(2, am // ai + 1):
        memo[ai * j] = 0
    p = ai

print(sum(memo))

Buggy python submission (verdict: Time Limit Exceeded):
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

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

dic = {}
for ai in a:
    if ai not in dic:
        dic[ai] = 0
    dic[ai] += 1

ans = 0

for ai in a:
    cnt = 0
    f = 1
    for i in range(1, int(ai**0.5)+1):
        if ai % i == 0:
            d = i
            if d in dic:
                cnt += dic[d]
            if d == ai:
                cnt -= 1
            if cnt > 0:
                f = 0
                break
            if i != ai // i:
                d = ai // i
                if d in dic:
                    cnt += dic[d]
                if d == ai:
                    cnt -= 1
                if cnt > 0:
                    f = 0
                    break

    ans += f

print(ans)
    

            




Fixed submission:
n = int(input())
a = list(map(int, input().split()))

a.sort()
am = a[-1]

memo = [0] * (am+1)

for ai in a:
    memo[ai] = 1

p = -1

for ai in a:
    if ai == p:
        memo[ai] = 0
        continue
    for j in range(2, am // ai + 1):
        memo[ai * j] = 0
    p = ai

print(sum(memo))

Buggy python submission (verdict: Time Limit Exceeded):
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

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

dic = {}
for ai in a:
    if ai not in dic:
        dic[ai] = 0
    dic[ai] += 1

ans = 0

for ai in a:
    cnt = 0
    f = 1
    for d in make_divisors(ai):
        if d in dic:
            cnt += dic[d]
        if d == ai:
            cnt -= 1
        if cnt > 0:
            f = 0
            break
    ans += f

print(ans)
    

            




Fixed submission:
n = int(input())
a = list(map(int, input().split()))

a.sort()
am = a[-1]

memo = [0] * (am+1)

for ai in a:
    memo[ai] = 1

p = -1

for ai in a:
    if ai == p:
        memo[ai] = 0
        continue
    for j in range(2, am // ai + 1):
        memo[ai * j] = 0
    p = ai

print(sum(memo))