Buggy python submission (verdict: Time Limit Exceeded):
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

def resolve():
    it = map(int, sys.stdin.read().split())
    N = next(it)
    A = [next(it) for i in range(N)]
    A.sort()
    AX2 = A[-1] // 2

    if N == 1:
        print(1)
        return
    if A[0] == 1:
        print(0 if A[1] == 1 else 1)
        return

    ax = []
    ans = j = 0

    i = 1
    while i < N:
        a0 = A[i-1]
        for x in ax:
            if a0 % x == 0:
                i += 1
                break
        else:
            if a0 <= AX2:
                ax.append(a0)
            if a0 == A[i]:
                for i in range(i+1, N):
                    if a0 != A[i]:
                        i += 1
                        break
                else:
                    break
                continue
            ans += 1
            i += 1

    if A[-2] != A[-1]:
        a0 = A[-1]
        for x in ax:
            if a0 % x == 0:
                break
        else:
            ans += 1

    print(ans)


if __name__ == "__main__":
    resolve()


Fixed submission:
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

def resolve():
    it = map(int, sys.stdin.read().split())
    N = next(it)
    A = [next(it) for i in range(N)]

    if N == 1:
        print(1)
        return

    ax = max(A)+1
    dp = [0]*ax
    for ai in A:
        da = dp[ai]
        if da > 1:
            continue
        dp[ai] += 1
        if da == 0:
            for aj in range(2*ai, ax, ai):
                dp[aj] = 2
        #print(dp)
    print(dp.count(1))


if __name__ == "__main__":
    resolve()

Buggy python submission (verdict: Time Limit Exceeded):
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

def resolve():
    it = map(int, sys.stdin.read().split())
    N = next(it)
    A = [next(it) for i in range(N)]
    A.sort()

    if N == 1:
        print(1)
        return
    if A[0] == 1:
        print(0 if A[1] == 1 else 1)
        return

    ax = set()
    ans = 0
    for i in range(1, N):
        a0 = A[i-1]

        for x in ax:
            if a0 % x == 0:
                break
        else:
            if a0 == A[i]:
                ax.add(a0)
                continue
            ax.add(a0)
            ans += 1

    a0 = A[-1]
    for x in ax:
        if a0 % x == 0:
            break
    else:
        ans += 1

    print(ans)


if __name__ == "__main__":
    resolve()


Fixed submission:
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

def resolve():
    it = map(int, sys.stdin.read().split())
    N = next(it)
    A = [next(it) for i in range(N)]

    if N == 1:
        print(1)
        return

    ax = max(A)+1
    dp = [0]*ax
    for ai in A:
        da = dp[ai]
        if da > 1:
            continue
        dp[ai] += 1
        if da == 0:
            for aj in range(2*ai, ax, ai):
                dp[aj] = 2
        #print(dp)
    print(dp.count(1))


if __name__ == "__main__":
    resolve()

Buggy python submission (verdict: Time Limit Exceeded):
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

def resolve():
    it = map(int, sys.stdin.read().split())
    N = next(it)
    A = [next(it) for i in range(N)]
    A.sort()

    if N == 1:
        print(1)
        return
    if A[0] == 1:
        print(0 if A[1] == 1 else 1)
        return

    ax = set()
    ans = 0
    for i in range(1, N):
        a0 = A[i-1]
        if A[i-1] == A[i]:
            ax.add(a0)
            continue

        for x in ax:
            if a0 % x == 0:
                break
        else:
            ax.add(a0)
            ans += 1

    a0 = A[-1]
    for x in ax:
        if a0 % x == 0:
            break
    else:
        ans += 1

    print(ans)


if __name__ == "__main__":
    resolve()


Fixed submission:
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

def resolve():
    it = map(int, sys.stdin.read().split())
    N = next(it)
    A = [next(it) for i in range(N)]

    if N == 1:
        print(1)
        return

    ax = max(A)+1
    dp = [0]*ax
    for ai in A:
        da = dp[ai]
        if da > 1:
            continue
        dp[ai] += 1
        if da == 0:
            for aj in range(2*ai, ax, ai):
                dp[aj] = 2
        #print(dp)
    print(dp.count(1))


if __name__ == "__main__":
    resolve()