Buggy python submission (verdict: Time Limit Exceeded):
def solve():
    n=int(input())
    a=list(map(int,input().split()))
    ans=0
    a2=set(a)
    a2=list(sorted(a2))
    num3=0
    if a2[0]==1:
        if a.count(1)==1:
            ans=1
        else:
            ans=0
    else:
        len2=len(a2)
        def c1(num1):
            return a.count(num1)
        def l1():
            return len(a2)
        for i in range(len2):
            num=0
            if c1(a2[i-num3])==1:
                for j in range(i-num3):
                    if a2[i-num3]%a2[j]==0:
                        num=1
                        a2.remove(a2[i-num3])
                        num3+=1
                        break
                    if a2[i-num3]/2+1<a2[j]:
                        break
                if num==0:
                    ans+=1
    print(ans)

solve()


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ans=0
a.sort()
num=a[-1]
dp=[True]*num
seen=[0]*num
for i in range(n):
    num2=a[i]
    if dp[num2-1]==True:
        if seen[num2-1]==1:
            dp[num2-1]=False
        for j in range(2,num//num2+1):
            dp[j*num2-1]=False
    seen[a[i]-1]=1
ans=0
for i in range(n):
    if dp[a[i]-1]==True:
        ans+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def solve():
    n=int(input())
    a=list(map(int,input().split()))
    ans=0
    a2=set(a)
    a2=list(sorted(a2))
    if a2[0]==1:
        if a.count(1)==1:
            ans=1
        else:
            ans=0
    else:
        def c1(num1):
            return a.count(num1)
        for i in range(len(a2)):
            num=0
            if c1(a2[i])==1:
                for j in range(i):
                    if a2[i]%a2[j]==0:
                        num=1
                        break
                    if a2[i]/2+1<a2[j]:
                        break
                if num==0:
                    ans+=1
    print(ans)

solve()


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ans=0
a.sort()
num=a[-1]
dp=[True]*num
seen=[0]*num
for i in range(n):
    num2=a[i]
    if dp[num2-1]==True:
        if seen[num2-1]==1:
            dp[num2-1]=False
        for j in range(2,num//num2+1):
            dp[j*num2-1]=False
    seen[a[i]-1]=1
ans=0
for i in range(n):
    if dp[a[i]-1]==True:
        ans+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def solve():
    n=int(input())
    a=list(map(int,input().split()))
    ans=0
    a2=set(a)
    a2=list(sorted(a2))
    def c1(num1):
        return a.count(num1)
    for i in range(len(a2)):
        num=0
        if c1(a2[i])==1:
            for j in range(i):
                if a2[i]%a2[j]==0:
                    num=1
                    break
                if a2[i]/2+1<a2[j]:
                    break
            if num==0:
                ans+=1
    print(ans)

solve()


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ans=0
a.sort()
num=a[-1]
dp=[True]*num
seen=[0]*num
for i in range(n):
    num2=a[i]
    if dp[num2-1]==True:
        if seen[num2-1]==1:
            dp[num2-1]=False
        for j in range(2,num//num2+1):
            dp[j*num2-1]=False
    seen[a[i]-1]=1
ans=0
for i in range(n):
    if dp[a[i]-1]==True:
        ans+=1
print(ans)