Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
arr = list(map(int, input().split()))
arr = sorted(arr)
m = arr[-1]
tf = [True] * (m+1)
cnt = 0
        
for i in range(n):
  ai = arr[i]
  if tf[ai] == True:
    cnt += 1
    for j in range(ai, m+1, ai):
      tf[j] = False
    if ai in arr[i+1:]:
      cnt -= 1
    

print(cnt)

Fixed submission:
n = int(input())
arr = list(map(int, input().split()))
arr = sorted(arr)
m = arr[-1]
li = [0]*(m+1)
cnt = 0
        
for i in arr:
  for j in range(i, m+1, i):
    li[j] += 1

for i in arr:
  if li[i] == 1:
    cnt += 1

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
arr = list(map(int, input().split()))
arr = sorted(arr)
maximum = arr[-1]
tf = [True] * (maximum+1)
cnt = 0
        
for i in range(n):
  ai = arr[i]
  if tf[ai] == True:
    cnt += 1
    for j in range(maximum//ai):
      tf[(j+1)*ai] = False
    if ai in arr[i+1:]:
      cnt -= 1
    

print(cnt)

Fixed submission:
n = int(input())
arr = list(map(int, input().split()))
arr = sorted(arr)
m = arr[-1]
li = [0]*(m+1)
cnt = 0
        
for i in arr:
  for j in range(i, m+1, i):
    li[j] += 1

for i in arr:
  if li[i] == 1:
    cnt += 1

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
arr = list(map(int, input().split()))
arr = sorted(arr)
maximum = arr[-1]
tf = [True] * (maximum+1)
cnt = 0
        
for i in range(n):
  ai = arr[i]
  if tf[ai] == True:
    cnt += 1
    for j in range(maximum//ai):
      tf[(j+1)*ai] = False
    if ai in arr[i+1:]:
      cnt -= 1
    

print(cnt)

Fixed submission:
n = int(input())
arr = list(map(int, input().split()))
arr = sorted(arr)
m = arr[-1]
li = [0]*(m+1)
cnt = 0
        
for i in arr:
  for j in range(i, m+1, i):
    li[j] += 1

for i in arr:
  if li[i] == 1:
    cnt += 1

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
arr = list(map(int, input().split()))
arr = sorted(arr)
cnt = 0
        
while len(arr):
  i = arr[0]
  tmp = []
  original = True
  for j in arr[1:]:
    if i == j:
      original = False
    if j % i != 0:
      tmp += [j]
  if original:
    cnt += 1
  arr = tmp
    

print(cnt)

Fixed submission:
n = int(input())
arr = list(map(int, input().split()))
arr = sorted(arr)
m = arr[-1]
li = [0]*(m+1)
cnt = 0
        
for i in arr:
  for j in range(i, m+1, i):
    li[j] += 1

for i in arr:
  if li[i] == 1:
    cnt += 1

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
arr = list(map(int, input().split()))
arr = sorted(arr)
cnt = 0
        
while len(arr):
  i = arr[0]
  original = True
  for j in arr[1:]:
    if j % i == 0:
      arr.remove(j)
      if i == j:
        original = False
  if original:
    cnt += 1
  arr.remove(i)
    

print(cnt)

Fixed submission:
n = int(input())
arr = list(map(int, input().split()))
arr = sorted(arr)
m = arr[-1]
li = [0]*(m+1)
cnt = 0
        
for i in arr:
  for j in range(i, m+1, i):
    li[j] += 1

for i in arr:
  if li[i] == 1:
    cnt += 1

print(cnt)

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

for i in range(len(arr)):
  for j in range(len(arr)):
    if arr[i] % arr[j] == 0 and i != j:
      cnt -= 1
      break

print(cnt)

Fixed submission:
n = int(input())
arr = list(map(int, input().split()))
arr = sorted(arr)
m = arr[-1]
li = [0]*(m+1)
cnt = 0
        
for i in arr:
  for j in range(i, m+1, i):
    li[j] += 1

for i in arr:
  if li[i] == 1:
    cnt += 1

print(cnt)

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

    i = 0
    count = 0

    while i < n:
        count += judge(i, arr, n)
        i += 1

    print(count)


def judge(i, arr, n):
    for j in range(n):
        if i != j:
            if arr[i] % arr[j] == 0:
                return 0
    return 1


main()

Fixed submission:
n = int(input())
arr = list(map(int, input().split()))
arr = sorted(arr)
m = arr[-1]
li = [0]*(m+1)
cnt = 0
        
for i in arr:
  for j in range(i, m+1, i):
    li[j] += 1

for i in arr:
  if li[i] == 1:
    cnt += 1

print(cnt)