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

a.sort()
if a[0] == 1:
    if len(a) == 1 or a[1] != 1:
        print(1)
    else:
        print(0)
else:
    a += [-1]
    ret = 0
    d_lst = []
    add = 1
    for i in range(n):
        if a[i] != a[i+1]:
            for d in d_lst:
                if a[i] % d == 0:
                    break
            else:
                ret += add
                d_lst.append(a[i])
                add = 1
        else:
            add = 0
    print(ret)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))

a.sort()
if a[0] == 1:
    if len(a) == 1 or a[1] != 1:
        print(1)
    else:
        print(0)
else:
    a_max = a[-1]
    seive = [True for _ in range(a_max + 1)]
    a += [-1]
    ret = 0
    add = 1
    for i in range(n):
        if a[i] != a[i+1]:
            if seive[a[i]]:
                ret += add
                j = 2 * a[i]
                while j <= a_max:
                    seive[j] = False
                    j += a[i]
            add = 1
        else:
            add = 0
    print(ret)

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

a.sort()
if a[0] == 1:
    if len(a) == 1 or a[1] != 1:
        print(1)
    else:
        print(0)
else:
    a += [-1]
    ret = 0
    d_lst = []
    add = 1
    for i in range(n):
        if a[i] != a[i+1]:
            for d in d_lst:
                if a[i] % d == 0:
                    break
            else:
                ret += add
                d_lst.append(a[i])
                add = 1
        else:
            add = 0
    print(ret)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))

a.sort()
if a[0] == 1:
    if len(a) == 1 or a[1] != 1:
        print(1)
    else:
        print(0)
else:
    a_max = a[-1]
    seive = [True for _ in range(a_max + 1)]
    a += [-1]
    ret = 0
    add = 1
    for i in range(n):
        if a[i] != a[i+1]:
            if seive[a[i]]:
                ret += add
                j = 2 * a[i]
                while j <= a_max:
                    seive[j] = False
                    j += a[i]
            add = 1
        else:
            add = 0
    print(ret)

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

a.sort()
if a[0] == 1:
    if a[1] != 1:
        print(1)
    else:
        print(0)
else:
    cnt = 1
    b = []
    for i in range(n-1):
        if a[i] != a[i+1]:
            b.append([a[i], cnt])
            cnt = 1
        else:
            cnt += 1
    b.append([a[n-1], cnt])

    ret = 0
    d_lst = []
    for c in b:
        num, cnt = c
        for d in d_lst:
            if num % d == 0:
                break
        else:
            if cnt == 1:
                ret += 1
            d_lst.append(num)

    print(ret)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))

a.sort()
if a[0] == 1:
    if len(a) == 1 or a[1] != 1:
        print(1)
    else:
        print(0)
else:
    a_max = a[-1]
    seive = [True for _ in range(a_max + 1)]
    a += [-1]
    ret = 0
    add = 1
    for i in range(n):
        if a[i] != a[i+1]:
            if seive[a[i]]:
                ret += add
                j = 2 * a[i]
                while j <= a_max:
                    seive[j] = False
                    j += a[i]
            add = 1
        else:
            add = 0
    print(ret)