Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_ls = list(map(int, input().split()))
a_ls.sort(reverse=True)
ans = 0
for i in range(n):
    not_divisible = True
    for j in range(i+1,n):
        if a_ls[i] % a_ls[j] == 0 or a_ls[i] == a_ls[j]:
            not_divisible = False
            break
    if i > 0 and a_ls[i-1] == a_ls[i]:
        not_divisible = False
    if not_divisible:
        ans += 1
print(ans)

Fixed submission:
n = int(input())
a_ls = list(map(int, input().split()))
a_ls.sort()
a_max = a_ls[-1]
times_ls = [0] * (a_max + 1)
divisible_ls = [0] * (a_max + 1)
for i in range(n):
    base = a_ls[i]
    times_ls[base] += 1
    times = 2
    while base*times <= a_max:
        divisible_ls[base*times] = 1
        times += 1
ans = 0
for i in range(1,a_max+1):
    if times_ls[i] == 1 and divisible_ls[i] == 0:
        ans += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a_ls = list(map(int, input().split()))
a_ls.sort(reverse=True)
ans = 0
for i in range(n):
    not_divisible = True
    for j in range(i+1,n):
        if a_ls[i] % a_ls[j] == 0:
            not_divisible = False
            break
    if not_divisible:
        ans += 1
if a_ls[-2] == a_ls[-1]:
    ans -= 1
print(ans)

Fixed submission:
n = int(input())
a_ls = list(map(int, input().split()))
a_ls.sort()
a_max = a_ls[-1]
times_ls = [0] * (a_max + 1)
divisible_ls = [0] * (a_max + 1)
for i in range(n):
    base = a_ls[i]
    times_ls[base] += 1
    times = 2
    while base*times <= a_max:
        divisible_ls[base*times] = 1
        times += 1
ans = 0
for i in range(1,a_max+1):
    if times_ls[i] == 1 and divisible_ls[i] == 0:
        ans += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a_ls = list(map(int, input().split()))
a_ls.sort(reverse=True)
ans = 0
for i in range(n):
    not_divisible = True
    for j in range(i+1,n):
        if a_ls[i] % a_ls[j] == 0:
            not_divisible = False
            break
    if not_divisible:
        ans += 1
if a_ls[-2] == a_ls[-1]:
    ans -= 1
print(ans)

Fixed submission:
n = int(input())
a_ls = list(map(int, input().split()))
a_ls.sort()
a_max = a_ls[-1]
times_ls = [0] * (a_max + 1)
divisible_ls = [0] * (a_max + 1)
for i in range(n):
    base = a_ls[i]
    times_ls[base] += 1
    times = 2
    while base*times <= a_max:
        divisible_ls[base*times] = 1
        times += 1
ans = 0
for i in range(1,a_max+1):
    if times_ls[i] == 1 and divisible_ls[i] == 0:
        ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_ls = list(map(int, input().split()))
a_ls.sort()
isinA = [0] * (a_ls[-1]+1)
for i in range(n):
    isinA[a_ls[i]] = 1

def make_divisors(n):
    divisors = []
    # 試し割りで、かつ積でnを作るときの相方も同時に追加してる
    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)

    divisors.sort()
    divisors.pop()
    return divisors

ans = 0
for i in range(n):
    divisors = make_divisors(a_ls[i])
    not_divisible = True
    for j in range(len(divisors)):
        if isinA[divisors[j]]:
            not_divisible = False
    if i > 0:
        if a_ls[i-1] == a_ls[i]:
            not_divisible = False
    if i < n-1:
        if a_ls[i+1] == a_ls[i]:
            not_divisible = False
    if not_divisible:
        ans += 1

print(ans)


Fixed submission:
n = int(input())
a_ls = list(map(int, input().split()))
a_ls.sort()
a_max = a_ls[-1]
times_ls = [0] * (a_max + 1)
divisible_ls = [0] * (a_max + 1)
for i in range(n):
    base = a_ls[i]
    times_ls[base] += 1
    times = 2
    while base*times <= a_max:
        divisible_ls[base*times] = 1
        times += 1
ans = 0
for i in range(1,a_max+1):
    if times_ls[i] == 1 and divisible_ls[i] == 0:
        ans += 1
print(ans)

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

ans = 0
for i in range(n):
    not_divisible = True
    for j in range(i):
        if a_ls[i] % a_ls[j] == 0:
            not_divisible = False
        if a_ls[i]//2 < a_ls[j]:
            break
    if i > 0:
        if a_ls[i-1] == a_ls[i]:
            not_divisible = False
    if i < n-1:
        if a_ls[i+1] == a_ls[i]:
            not_divisible = False
    if not_divisible:
        ans += 1
print(ans)


Fixed submission:
n = int(input())
a_ls = list(map(int, input().split()))
a_ls.sort()
a_max = a_ls[-1]
times_ls = [0] * (a_max + 1)
divisible_ls = [0] * (a_max + 1)
for i in range(n):
    base = a_ls[i]
    times_ls[base] += 1
    times = 2
    while base*times <= a_max:
        divisible_ls[base*times] = 1
        times += 1
ans = 0
for i in range(1,a_max+1):
    if times_ls[i] == 1 and divisible_ls[i] == 0:
        ans += 1
print(ans)