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

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

ans = 0
div = []
for i in range(n):
    if 0 < i and a[i] == a[i-1]:
        if i < n-1 and a[i] != a[i+1]:
            div += [a[i]]
        continue
    if i < n-1 and a[i] == a[i+1]:
        continue

    b = True
    for x in div:
        if a[i] < x * 2:
            break
        if a[i] % x == 0:
            b = False
    if b:
        ans += 1
        div += [a[i]]

print(ans)

Fixed submission:
n = int(input())
a = sorted(list(map(int,input().split())))
m = a[-1]
b = [True]*(m+1)
for i in range(n):
    if i > 0 and a[i] == a[i-1]:
        continue
    for j in range(2, m//a[i]+1):
        b[j*a[i]] = False
ans = 0
for i in range(n):
    if 0 < i and a[i] == a[i-1]:
        continue
    if i < n-1 and a[i] == a[i+1]:
        continue
    if b[a[i]]:
        ans += 1
print(ans)

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

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

ans = 0
div = []
for i in range(n):
    if 0 < i and a[i] == a[i-1]:
        div += [a[i]]
        continue
    if i < n-1 and a[i] == a[i+1]:
        continue

    b = True
    for x in div:
        if a[i] < x * 2:
            break
        if a[i] % x == 0:
            b = False
    if b:
        ans += 1
        div += [a[i]]

print(ans)

Fixed submission:
n = int(input())
a = sorted(list(map(int,input().split())))
m = a[-1]
b = [True]*(m+1)
for i in range(n):
    if i > 0 and a[i] == a[i-1]:
        continue
    for j in range(2, m//a[i]+1):
        b[j*a[i]] = False
ans = 0
for i in range(n):
    if 0 < i and a[i] == a[i-1]:
        continue
    if i < n-1 and a[i] == a[i+1]:
        continue
    if b[a[i]]:
        ans += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = sorted(list(map(int,input().split())))

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

b = [True]*n
fix = [False]*n
for i in range(n):
    if not b[i] or fix[i]:
        continue
    if i < n and a[i] == a[i+1]:
        b[i] = False
        fix[i] = True
    for j in range(i+1, n):
        if a[i] < a[j] < a[i]*2:
            fix[j] = True
            continue
        if a[j] % a[i] == 0:
            fix[j] = True
            b[j] = False

print(sum(b))

Fixed submission:
n = int(input())
a = sorted(list(map(int,input().split())))
m = a[-1]
b = [True]*(m+1)
for i in range(n):
    if i > 0 and a[i] == a[i-1]:
        continue
    for j in range(2, m//a[i]+1):
        b[j*a[i]] = False
ans = 0
for i in range(n):
    if 0 < i and a[i] == a[i-1]:
        continue
    if i < n-1 and a[i] == a[i+1]:
        continue
    if b[a[i]]:
        ans += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = sorted(list(map(int,input().split())))
b = []
if a[0] != a[1]:
    b += [a[0]]
for i in range(1, n-1):
    if a[i-1] != a[i] and a[i] != a[i+1]:
        b += [a[i]]
if a[-1] != a[-2]:
    b += [a[-1]]

if len(b) == 0:
    print(0)
    exit()
ans = 1
div = [b[0]]
for x in b[1:]:
    f = True
    for d in div:
        if x % d == 0:
            f = False
            break
    if f:
        div += [x]
        ans += 1
print(ans)

Fixed submission:
n = int(input())
a = sorted(list(map(int,input().split())))
m = a[-1]
b = [True]*(m+1)
for i in range(n):
    if i > 0 and a[i] == a[i-1]:
        continue
    for j in range(2, m//a[i]+1):
        b[j*a[i]] = False
ans = 0
for i in range(n):
    if 0 < i and a[i] == a[i-1]:
        continue
    if i < n-1 and a[i] == a[i+1]:
        continue
    if b[a[i]]:
        ans += 1
print(ans)