Buggy python submission (verdict: Runtime Error):
def resolve():
    import bisect
    import math
    n = int(input())
    a = list(map(int, input().split()))
    a1 = {}
    for i in range(len(a)):
        if a[i] in a1:
            a1[a[i]] += 1
        else:
            a1[a[i]] = 1
    a = sorted(list(a1.keys()))
    ans = [1]*len(a)

    if len(a) != 1:
        for i in range(len(a)):
            if a[i] > a[-1]/a[0]:
                break
            if ans[i] == 1:
                for j in range(i+1, n):
                    if a[j] % a[i] == 0:
                        ans[j] = 0
    ans1 = 0
    for j in range(len(a)):
        if ans[j] == 1 and a1[a[j]] == 1:
            ans1 += 1
    print(ans1)
resolve()

Fixed submission:
def resolve():
    n = int(input())
    a = list(map(int, input().split()))
    a1 = {}
    for i in range(len(a)):
        if a[i] in a1:
            a1[a[i]] += 1
        else:
            a1[a[i]] = 1
    a = sorted(list(a1.keys()))
    ans = [1] * a[-1]

    for i in a:
        if ans[i-1] == 1:
            for j in range(i-1, len(ans), i):
                ans[j] = 0
            ans[i-1] =1
    ans1 = 0
    for i in a:
        if a1[i] == 1:
            ans1 += ans[i-1]
    print(ans1)
resolve()

Buggy python submission (verdict: Runtime Error):
def resolve():
    import bisect
    import math
    n = int(input())
    a = list(map(int, input().split()))
    a = sorted(a)
    maxa = a[-1]
    maxi = bisect.bisect_right(a, math.ceil(maxa**0.5))

    ans = [1]*n
    for i in range(0, maxi+1):
        if ans[i] == 1:
            for j in range(i+1, n):
                if ans[j] == 0:
                    continue
                if a[j] == a[i]:
                    ans[i] = 0
                if a[j] % a[i] ==0:
                    ans[j] = 0
    print(sum(ans))
resolve()

Fixed submission:
def resolve():
    n = int(input())
    a = list(map(int, input().split()))
    a1 = {}
    for i in range(len(a)):
        if a[i] in a1:
            a1[a[i]] += 1
        else:
            a1[a[i]] = 1
    a = sorted(list(a1.keys()))
    ans = [1] * a[-1]

    for i in a:
        if ans[i-1] == 1:
            for j in range(i-1, len(ans), i):
                ans[j] = 0
            ans[i-1] =1
    ans1 = 0
    for i in a:
        if a1[i] == 1:
            ans1 += ans[i-1]
    print(ans1)
resolve()

Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    n = int(input())
    a = list(map(int, input().split()))
    a = sorted(a)
    ans = [1]*n
    for i in range(n):
        if ans[i] == 1:
            for j in range(i+1, n):
                if a[j] == a[i]:
                    ans[i] = 0
                if a[j]%a[i] ==0:
                    ans[j] = 0
    print(sum(ans))
resolve()

Fixed submission:
def resolve():
    n = int(input())
    a = list(map(int, input().split()))
    a1 = {}
    for i in range(len(a)):
        if a[i] in a1:
            a1[a[i]] += 1
        else:
            a1[a[i]] = 1
    a = sorted(list(a1.keys()))
    ans = [1] * a[-1]

    for i in a:
        if ans[i-1] == 1:
            for j in range(i-1, len(ans), i):
                ans[j] = 0
            ans[i-1] =1
    ans1 = 0
    for i in a:
        if a1[i] == 1:
            ans1 += ans[i-1]
    print(ans1)
resolve()