Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
a.sort()
if a[0]==1:
    if n==1 or a[1]>1:
        print(1)
    else:
        print(0)
    exit(0)
seen = []
same = set()
ans = 0
pre = -1
flg = False
for i in a:
    if i==pre:
        if flg:
            same.add(i)
        continue
    pre = i
    flg = True
    for j in seen:
        if j*2>i:
            break
        if i%j==0:
            flg = False
            break
    if flg:
        ans += 1
        seen.append(i)
print(ans-len(same))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
a.sort()
if a[0]==1:
    if n==1 or a[1]>1:
        print(1)
    else:
        print(0)
    exit(0)
ok = [True]*(10**6+1)
ans = 0
pre = -1
for i in a:
    if not ok[i]:
        continue
    if i==pre:
        ok[i] = False
        continue
    pre = i
    for j in range(i*2, 10**6+1, i):
        ok[j] = False
for i in a:
    if ok[i]:
        ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
a.sort()
seen = []
same = set()
ans = 0
pre = -1
flg = False
for i in a:
    if i==pre:
        if flg:
            same.add(i)
        continue
    pre = i
    flg = True
    for j in seen:
        if j*2>i:
            break
        if i%j==0:
            flg = False
            break
    if flg:
        ans += 1
        seen.append(i)
print(ans-len(same))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
a.sort()
if a[0]==1:
    if n==1 or a[1]>1:
        print(1)
    else:
        print(0)
    exit(0)
ok = [True]*(10**6+1)
ans = 0
pre = -1
for i in a:
    if not ok[i]:
        continue
    if i==pre:
        ok[i] = False
        continue
    pre = i
    for j in range(i*2, 10**6+1, i):
        ok[j] = False
for i in a:
    if ok[i]:
        ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
a.sort()
seen = set()
same = set()
ans = 0
for i in a:
    if i in seen:
        same.add(i)
        continue
    for j in seen:
        if i%j==0:
            break
    else:
        ans += 1
        seen.add(i)
print(ans-len(same))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
a.sort()
if a[0]==1:
    if n==1 or a[1]>1:
        print(1)
    else:
        print(0)
    exit(0)
ok = [True]*(10**6+1)
ans = 0
pre = -1
for i in a:
    if not ok[i]:
        continue
    if i==pre:
        ok[i] = False
        continue
    pre = i
    for j in range(i*2, 10**6+1, i):
        ok[j] = False
for i in a:
    if ok[i]:
        ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
a.sort()
seen = set()
same = set()
ans = 0
for i in a:
    if i in seen:
        same.add(i)
        continue
    for j in seen:
        if i%j==0:
            break
    else:
        ans += 1
        seen.add(i)
print(ans-len(same))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
a.sort()
if a[0]==1:
    if n==1 or a[1]>1:
        print(1)
    else:
        print(0)
    exit(0)
ok = [True]*(10**6+1)
ans = 0
pre = -1
for i in a:
    if not ok[i]:
        continue
    if i==pre:
        ok[i] = False
        continue
    pre = i
    for j in range(i*2, 10**6+1, i):
        ok[j] = False
for i in a:
    if ok[i]:
        ans += 1
print(ans)