Buggy python submission (verdict: Time Limit Exceeded):
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    return divisors


def main():

    N = in_n()
    A = list(in_nn())

    d = dict()
    for i in range(N):
        if A[i] in d:
            d[A[i]] += 1
        else:
            d[A[i]] = 1

    ans = 0
    for i in range(N):
        for num in make_divisors(A[i]):
            if num == A[i]:
                if d.get(num, 0) >= 2:
                    break
            else:
                if d.get(num, 0) >= 1:
                    break
        else:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():

    N = in_n()
    A = sorted(list(in_nn()))

    maxA = max(A)
    ans = [True] * (maxA + 1)
    d = set()

    for i in range(N):
        if A[i] in d:
            ans[A[i]] = False
        for j in range(A[i] * 2, maxA + 1, A[i]):
            if not j:
                break
            else:
                ans[j] = False
        d |= {A[i]}

    count = 0
    for i in range(N):
        count += ans[A[i]]

    print(count)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


def main():

    N = in_n()
    A = list(in_nn())

    d = defaultdict(lambda: 0)
    for i in range(N):
        d[A[i]] += 1

    ans = 0
    for i in range(N):
        for num in make_divisors(A[i]):
            #print(A[i], num)
            if num == A[i]:
                if d[num] >= 2:
                    break
            else:
                if d[num] >= 1:
                    break
        else:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():

    N = in_n()
    A = sorted(list(in_nn()))

    maxA = max(A)
    ans = [True] * (maxA + 1)
    d = set()

    for i in range(N):
        if A[i] in d:
            ans[A[i]] = False
        for j in range(A[i] * 2, maxA + 1, A[i]):
            if not j:
                break
            else:
                ans[j] = False
        d |= {A[i]}

    count = 0
    for i in range(N):
        count += ans[A[i]]

    print(count)


if __name__ == '__main__':
    main()