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

A.sort()
B = [0]*N

for i in range(N):
    if B[i]:
        continue
    if i < N-1:
        if A[i] == A[i+1]:
            B[i] = 1
    x = A[i]
    for j in range(i+1, N):
        if B[j]:
            continue
        if A[j]%x == 0:
            B[j] = 1

print(N-sum(B))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
A.sort()

dlen = A[-1]+3
d = [True]*dlen
for a in A:
    if d[a]:
        for i in range(a*2, dlen, a):
            d[i] = False

res = 0
for i in range(N):
    if i > 0:
        if A[i] == A[i-1]:
            continue
    if i < N-1:
        if A[i] == A[i+1]:
            continue
    if d[A[i]]:
        res += 1
print(res)

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

A.sort()
B = [0]*N

for i in range(N):
    if B[i]:
        continue
    if i < N-1:
        if A[i] == A[i+1]:
            B[i] = 1
    x = A[i]
    for j in range(i+1, N):
        if A[j]%x == 0:
            B[j] = 1

print(N-sum(B))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
A.sort()

dlen = A[-1]+3
d = [True]*dlen
for a in A:
    if d[a]:
        for i in range(a*2, dlen, a):
            d[i] = False

res = 0
for i in range(N):
    if i > 0:
        if A[i] == A[i-1]:
            continue
    if i < N-1:
        if A[i] == A[i+1]:
            continue
    if d[A[i]]:
        res += 1
print(res)

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

A.sort()
res = N
for i in range(N):
    if i != N-1:
        if A[i] == A[i+1]:
            res -= 1
            continue
    if i != 0:
        if A[i] == A[i-1]:
            res -= 1
            continue

    for j in range(0, i):
        if A[i]%A[j]==0:
            res -= 1
            break
        if A[j]*2 > A[i]:
            break
print(res)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
A.sort()

dlen = A[-1]+3
d = [True]*dlen
for a in A:
    if d[a]:
        for i in range(a*2, dlen, a):
            d[i] = False

res = 0
for i in range(N):
    if i > 0:
        if A[i] == A[i-1]:
            continue
    if i < N-1:
        if A[i] == A[i+1]:
            continue
    if d[A[i]]:
        res += 1
print(res)

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

A.sort()
res = N
for i in range(N):
    if i != N-1:
        if A[i] == A[i+1]:
            res -= 1
            continue
    if i != 0:
        if A[i] == A[i-1]:
            res -= 1
            continue

    for j in range(0, i):
        if A[i]%A[j]==0:
            res -= 1
            break
        if A[j]*2 > A[i]:
            break
print(res)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
A.sort()

dlen = A[-1]+3
d = [True]*dlen
for a in A:
    if d[a]:
        for i in range(a*2, dlen, a):
            d[i] = False

res = 0
for i in range(N):
    if i > 0:
        if A[i] == A[i-1]:
            continue
    if i < N-1:
        if A[i] == A[i+1]:
            continue
    if d[A[i]]:
        res += 1
print(res)

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

A.sort()
res = N
for i in range(N):
    if i != N-1:
        if A[i] == A[i+1]:
            res -= 1
            continue
    if i != 0:
        if A[i] == A[i-1]:
            res -= 1
            continue

    for j in range(0, i):
        if A[i]%A[j]==0:
            res -= 1
            break
print(res)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
A.sort()

dlen = A[-1]+3
d = [True]*dlen
for a in A:
    if d[a]:
        for i in range(a*2, dlen, a):
            d[i] = False

res = 0
for i in range(N):
    if i > 0:
        if A[i] == A[i-1]:
            continue
    if i < N-1:
        if A[i] == A[i+1]:
            continue
    if d[A[i]]:
        res += 1
print(res)