Problem:


Score : 400 points

Problem Statement

Given is a number sequence A of length N.

Find the number of integers i \left(1 \leq i \leq N\right) with the following property:

For every integer j \left(1 \leq j \leq N\right) such that i \neq j , A_j does not divide A_i.

Constraints

All values in input are integers.

1 \leq N \leq 2 \times 10^5

1 \leq A_i \leq 10^6

Input

Input is given from Standard Input in the following format:

N
A_1 A_2 \cdots A_N

Output

Print the answer.

Sample Input 1

5
24 11 8 3 16

Sample Output 1

3

The integers with the property are 2, 3, and 4.

Sample Input 2

4
5 5 5 5

Sample Output 2

0

Note that there can be multiple equal numbers.

Sample Input 3

10
33 18 45 28 8 19 89 86 2 4

Sample Output 3

5



Sample input:
5
24 11 8 3 16


Sample output:
3

Submission status: Runtime Error

Solution code:
import sys
import time
#from collections import deque, Counter, defaultdict
#from fractions import gcd
import bisect
#import heapq
import math
import sympy
sympy.divisors(10**9)
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))
n = rl()
a=rl()
a.sort()
b=[0]*5*10**5
ans=[]

for i in a:

    if b[i]==1:
        if ans:
            if i in ans:
                ans.remove(i)
        continue
    f=True
    for j in sympy.divisors(i):
        if b[j]==1:
            f=False
            break
    if f:
        b[i]=1
        ans.append(i)
print(len(ans))

Submission status: Runtime Error

Solution code:
import numpy as np
n = int(input())
p = input().split()
for i in range(len(p)):
    p[i] = int(p[i])

matrix = np.zeros((n,n))
done = [0]*n
result = 0
for i in range(n):
    for j in range(i+1,n):
        a = p[i]
        b = p[j]
        if a > b and a % b == 0:
            matrix[i,j] = 1
            matrix[j,i] = 1
        elif a <= b and b % a == 0:
            matrix[i,j] = 1
            matrix[j,i] = 1

matrix_sum = np.sum(matrix, axis = 0)

# case: k = 0
for i in range(n):
    if matrix_sum[i] == 0:
        result += 1
        done[i] = 1

k = 1
while True:
    print("start: ", done)
    if np.sum(done) == n:
        break
    for i in range(n):
        print(matrix_sum[i], k)
        if matrix_sum[i] == k and done[i] == 0:
            index_found = np.where(matrix[i,:] == 1)[0]
            print("index", index_found)
            for j in range(len(index_found)):
                done[index_found[j]] = 1
                print("1", done)
            result += 1
            done[i] = 1
            print("result", result)
            print("2", done)
    k += 1
            
print(result)

Submission status: Runtime Error

Solution code:
num = int(input())
input_line = list(map(int,input().split(' ')))
input_line.sort()
ans = num

for i in range(num):
    now = input_line[i]
    for j in range(num):
        if(i==0):
            if(now%input_line[1]==0):
                ans-=1
                break
        if(i>j):
            if(now%input_line[j]==0):
                ans-=1
                break
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int,input().split()))

a.sort()

def zansa(a0, alist):
    ans=[]
    for i in range(len(alist)):
        if alist[i] % a0 != 0:
            ans.append(alist[i])
    return ans

an = []
if a[0]==a[n-1] or n==0:
    pass
else:
    for j in range(n-1):
        # print(a[0])
        an.append(a[0])
        if len(a) >1:
            a = zansa(a[0],a[1:])
        else:
            break

print(len(an))

Submission status: Runtime Error

Solution code:
import numpy as np
import sympy as sp
n = int(input())
a = list(map(int, input().split()))
a.sort()
flag = [True] * n
for i, num in enumerate(a):
    div = sp.divisors(num)
    for d in div:
        if d == num:
            if a.count(d)>1:
                flag[i] = False
            continue
        if d in a:
            flag[i] = False
print(np.count_nonzero(flag))

Submission status: Runtime Error

Solution code:
n = int(input())
li = list(map(int, input().split()))
a = 0
for i in li:
    li1 = list(li)
    li1.remove(i)
    print(li1)
    if all(i % j != 0 for j in li1):
        a += 1
print(a)

Submission status: Runtime Error

Solution code:
N = int(input())
A = [int(x) for x in input().split()]
B = sorted(list(set(A)))

if len(B)>=2:
    NotD = 0
    for T in range(1,len(B)):
        Target = B[T]
        Count = 0
        if A.count[Target]==1:
            for TT in range(0,T):
                BY = B[TT]
                if Target%BY==0:
                    break
                else:
                    Count += 1
            if Count==T:
                NotD += 1
    print(NotD+1)
elif len(B)==1 and len(A)==1:
    print(1)
else:
    print(0)

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
c=0
for i in range(n):
  if i==n-1:
    if max(a)>a[n-1]:
      c+=1
      break
  for j in range(n-i-1):
    d=0
    if i==n-1-j:
      continue
    elif a[i]%a[n-1-j]==0:
      d+=1
      break
  if d==0:
     c+=1
print(c)

Submission status: Runtime Error

Solution code:
from sys import stdin
import sys

MAX_A = 1000000;
N = int(stdin.readline().rstrip())
A = sorted([int(x) for x in stdin.readline().rstrip().split()])
A_one = [x for x in set(A) if A.count(x) == 1]
A = list(set(A))
M = [False]*MAX_A
ans = 0
for a in A:
  if M[a] == False:
    if a in A_one:
    	ans+=1
    M[::a] = [True]*(len(M[::a]))
    
print(ans)

Submission status: Runtime Error

Solution code:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    a.sort()
    ans = 0
    if a[0] != a[1]:
        ans += 1

    for i in range(1, n):
        flg = True
        if i != n - 1:
            if a[i] == a[i - 1] or a[i] == a[i + 1]:
                continue
        else:
            if a[i] == a[i - 1]:
                continue

        for j in range(i):
            if a[i] % a[j] == 0:
                flg = False
                break
            if a[j] * 2 > a[i]:
                break
        if flg:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import numpy as np
n = int(input())
p = input().split()
for i in range(len(p)):
    p[i] = int(p[i])

matrix = np.zeros((n,n))
done = [0]*n
result = 0
for i in range(n):
    for j in range(i+1,n):
        a = p[i]
        b = p[j]
        if a > b and a % b == 0:
            matrix[i,j] = 1
            matrix[j,i] = 1
        elif a <= b and b % a == 0:
            matrix[i,j] = 1
            matrix[j,i] = 1

matrix_sum = np.sum(matrix, axis = 0)

# case: k = 0
for i in range(n):
    if matrix_sum[i] == 0:
        result += 1
        done[i] = 1

print(matrix)
print(matrix_sum)

k = 1
while True:
    print("start: ", done)
    if np.sum(done) == n:
        break
    for i in range(n):
        print(matrix_sum[i], k)
        if matrix_sum[i] == k and done[i] == 0:
            index_found = np.where(matrix[i,:] == 1)[0]
            print("index", index_found)
            for j in range(len(index_found)):
                done[index_found[j]] = 1
                print("1", done)
            result += 1
            done[i] = 1
            print("result", result)
            print("2", done)
    k += 1
            
print(result)

Submission status: Runtime Error

Solution code:
import sys 
from collections import deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
A = list(map(int,readline().split()))
A = list(sorted(A))
q = deque(A)
ans = 0
while q:
  t = q.popleft()
  cnt = q.count(t)
  if t == 1:
    if cnt == 0:
      print(1)
      sys.exit()
    else:
      print(0)
      sys.exit()
  if cnt == 0:
    ans += 1
  count = 0
  for j in range(len(q)):
    if q[j] % t == 0:
      count +=1
      q.remove(q[j])
      q.appendleft(1)
    for i in range(count):
      q.remove(1)
print(ans)

Submission status: Runtime Error

Solution code:
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 sorted(divisors, reverse=True)


N = int(input())
A = list(map(int, input().split()))

if N == 1:
    print(1)
    
A = sorted(A)
check_list = [0] * (10**6 + 1)

for a in A:
    check_list[a] = 1

cnt = 0
prev_val = -1
next_val = A[1]
for i in range(len(A)):
    if prev_val == A[i]:
        continue        
    prev_val = A[i]
    if len(A) - 1 != i:
        next_val = A[i + 1]
        if next_val == A[i]:
            continue
    divisors = make_divisors(A[i])[1:-1]
    check_ok = True
    for d in divisors:
       if check_list[d] == 1:
           check_ok = False
    if check_ok == True:
        cnt += 1
print(cnt)

Submission status: Runtime Error

Solution code:
import sys


def Sieve(N, AList):
    AList.sort()
    N_NotDivisible = 0
    while( len(AList) > 0 ):
        if(len(AList) > 1):
            if(AList[0]!= AList[1]):
                N_NotDivisible+= 1
                value = AList[0]
                AList.pop(0)
                AList = [ i for i in AList if i % value != 0 ]
            else:
                index = 1
                while(index < N and AList[0] == AList[index]):
                    index += 1
                Times = index+1
                for i in range(Times):
                    AList.pop(0)

        else:
            N_NotDivisible+= 1
            break
    #print(Mins)
    return N_NotDivisible

if(__name__ == "__main__"):

    N = int( input().strip() )
    AList_str = input().strip().split()

    AList = [0] * N
    for i in range(N):
        AList[i] = int(AList_str[i])
    N_NotDivisible= Sieve(N, AList)
    print(N_NotDivisible)

Submission status: Runtime Error

Solution code:
n = int(input())
a = sorted(list(map(int, input().split())))

MAX_VAL = 2*10**5
prime = [1] * (MAX_VAL+1)
prime[0] = prime[1] = 0
for i in range(2, int(MAX_VAL**0.5)+1):
    if prime[i]:
        for k in range(2*i, MAX_VAL+1, i):
            prime[k] = 0

res = []
for i in range(n):
    prev = a[i-1] if i > 0 else -1
    next = a[i+1] if i < n-1 else -1
    if a[i] == prev or a[i] == next:
        continue
    if prime[a[i]]:
        res.append(a[i])
        continue

    for v in res:
        if a[i] % v == 0:
            break
    else:
        res.append(a[i])

print(len(res))

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
def resolve():
    N,=pin()
    
        
    A=list(set(pin()))
    B=sorted(A)
    #print(B)

    ans=1
    if len(B)==1:
        print(0)#what?
        return
    if B[0]<B[1]:ans+=1
    
    must_see=[]
    must_see.append(B[0])
    
    """
    for cnt in range(1,10**7):
        if cnt>=N:break
        temp=B[cnt]
        cond=1
        for i in must_see:
            shit+=1
            if temp%i==0:
                cond=0
                break
        if cond==1:
            ans+=1
            must_see.append(temp)
    print(ans)
    """
    ans=B[:]
    x=[]
    for i in range(10**7):
        if i == len(ans):
            break
        temp=A[i]
        for j in ans:
        
            if j!=temp and j%temp==0:
                #iremasen
                continue
            else:
                #iremasu
                x.append(j)
        ans=x[:]
        #print(i,ans)
        x=[]
    print(len(ans))
    

#%%submit!
resolve()

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))

import numpy as np

ans = 0
for i in range(N):
    if len(A_re) == 0:
        ans = 0
        break
        break
    c = [j for j in A[i]/np.array(A) if j.is_integer() ]
    #print(c)
    if len(c) == 1:
        ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
As = list(map(int, input().split()))
As.sort()
if As[0] == As[1]:
    ans = 0
else:
    ans =1
#print(As)
for n in range(N):
    i = 0
    while i != n:
        if As[n] % As[i] != 0:
            i += 1
        elif As[n] == As[i]:
            break
        else:
            break
    if i == n and i != 0:
        ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
def main():
    import sympy
    from collections import Counter
    n = int(input())
    A = list(map(int, input().split()))
    s = set(A)
    c = Counter(A)
    cnt = 0
    for a in A:
        if c[a] > 1:
            continue
        else:
            d = set(sympy.divisors(a))
            if len(d & s) == 1:
                cnt += 1
    print(cnt)
main()

Submission status: Runtime Error

Solution code:
n = int(input())
list_ = list(map(int, input().split()))
set_ = set(list_)
cnt = 0

for i in range(len(set_)):
    flag = True
    for j in range(n):
        if i == j:
            continue

        if set_[i] % set_[j] == 0:
            flag = False
            break

    if flag:
        cnt += 1

print(cnt)

Submission status: Runtime Error

Solution code:
N = int(input())
good = N
i = 0
A = [int(x) for x in input().split()]
A.sort(reverse=True)
for i in range(N):
    if A[i]==A[i-1] and i >= 1:
        good -= 1
        continue
    elif A[i]==A[i+1]:
        good -= 1
        continue
    for j in range(i+1,N):
        if A[i]%A[N-j+i]==0:
            good -= 1
            break
print(good)

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
ans = 0
A = sorted(A)
print(A)
if N == 0:
  ans = 0
else:
  for i in range(len(A)-1,-1,-1):
    for j in range(0,i+1,1):
      print(i,j)
      if i==j:
        ans+=1
        if i==0 and A[0]==A[1]:
          ans-=1
        break
      if A[i]%A[j]==0:
        break
      if A[i]<A[j]*2:
        ans+=1
        break

print(ans)

Submission status: Runtime Error

Solution code:
N=int(input())
A=[int(_) for _ in input().split(" ")]

A.sort(reverse=True)
#print(A)

ans=[]

flg=0 
for i in range(N):
  flg=0
  if i == 0:
    if A[i]==A[i+1]:
      flg=1
  elif i==N-1:
    if A[i]==A[i-1]:
      flg=1
  else:
    if A[i]==A[i+1] or A[i]==A[i-1]:
      flg=1

  if flg == 0:
    for j in range(0,N-1-i):
      #print(i,j,A[i],A[N-1-j])
      if A[i] % A[N-1-j] == 0:
        flg=1
        break
      if A[i]/2 < A[N-1-j]:
        break
      
  if flg == 0:
    ans.append(i)
  else:
    flg = 0

#print(ans)
print(len(ans))

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))

A.sort()
C=[]

while A[0] != "f,opwrkfrke":
    B =[]
    for n in range(1,len(A)):
        if A[n] % A[0] !=0:
            B.append(A[n])
        
    if A[0] != A[1]:
        
        C.append(A[0])
    #print(A,B,C)
    A = B
    if len(A)==0:
        break
    Al = max(A)
    if A[0] == Al:
        C.append(B)
        break
#print(C)
if len(C)>0:
    print(len(C))
else:
    print(0)

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int,input().split()))
a.sort()
ans = 0
if a[0] != a[1]:
    ans += 1
for i in range(1,n):
    if a[i] != a[i-1]:
        div = True
        for j in range(i):
            if a[i] < 2*a[j]:
                if i < n-1 and a[i] == a[i+1]:
                    div = False
                break
            if a[i]%a[j] == 0:
                div = False
                break
        if div:
            ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))

import numpy as np

ans = 0
for i in range(N):
    if len(A_re) == 0:
        ans = 0
        break
        break
    c = [j for j in A[i]/np.array(A) if j.is_integer() ]
    print(c)
    if len(c) == 1:
        ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
# /usr/bin/python3
# -*- coding: utf-8 -*-
from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt, floor, ceil, log2, log10, pi
from fractions import gcd
from itertools import permutations, combinations
from operator import itemgetter
from functools import cmp_to_key

# from numpy import gcd


INF=1001001001
__MOD__=(10**9)+7
yn = 'YNeos'
judge = False
cnt = 0
ans = None


def lcm(a, b):
    return (a*b) // gcd(a,b)

def intinput():
    return int(input())

def mulinputs():
    return map(int,input().split())

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas

class ModInt():
    def __init__(self, x):
        self.__x = (x % __MOD__)
    def __add__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x + other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x + other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __radd__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x + self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x + self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __sub__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x - other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x - other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rsub__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x - self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x - self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __mul__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rmul__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x * self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x * self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __truediv__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__modinv())%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__modinv())%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rtruediv__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x * self.__modinv())%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x * self.__modinv())%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __pow__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__(pow(self.__x, other.__x, __MOD__)))
        elif type(other) == ModInt:
            return self.__class__(pow(self.__x, other.__x, __MOD__))
        else:
            raise Exception("Not Int or Not ModInt")
    def __rpow__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__(pow(other.__x, self.__x, __MOD__)))
        elif type(other) == ModInt:
            return self.__class__(pow(other.__x, self.__x, __MOD__))
        else:
            raise Exception("Not Int or Not ModInt")

    def __modinv(self, m=__MOD__):
        a = self.__x
        if a == 0:
            raise ZeroDivisionError()
        if gcd(a, m) != 1:
            raise Exception("%sの逆数は求まりません。" % a)
        b, u, v = m, 1, 0
        while b != 0:
            t = a//b;
            a -= t*b
            a, b = b, a
            u -= t * v
            u, v = v, u
        u %= m
        if u < 0:
            u += m
        return u
    def __int__(self):
        return self.__x
    def __str__(self):
        return str(self.__x)



if __name__ == '__main__':
    N = intinput()
    datas = list(mulinputs())


    ds = set(datas)
    if len(ds) <= 1:
        print(0)
        exit()
    ds = list(ds)
    ds.sort()
    if ds[0] == 1:
        print(0)
        exit()
    p = []
    # while ds:
    l = len(ds)
    for _ in range(sqrt(l)):
        tmp = ds.pop(0)
        if not ds:
            p.append(tmp)
            break
        ds = [ d for d in ds if d % tmp != 0]
        # if len(datas) == 0:
        #     print(len(p))
        #     exit()
        p.append(tmp)

    # 出力
    print(len(p))

Submission status: Runtime Error

Solution code:
n = int(input())
li = list(map(int, input().split()))
a = 0
for i in li:
    li1 = list(li)
    li1.remove(i)
    print(li1)
    if all(i % j for j in li1):
        a += 1
print(a)

Submission status: Runtime Error

Solution code:
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]

N = int(input())
a = list(map(int,input().split()))
a.sort()

d = [0 for i in range(max(a)+1)]
for i in range(N):
    d[a[i]] += 1
ans = 0

for i in range(N):
    divisors = make_divisors(a[i])
    flag = 1
    d[a[i]] -= 1
    for d_temp in divisors:
        if d[d_temp] > 0:
            flag = 0
    if flag == 1:
        ans += 1
    else:
        
    d[a[i]] += 1

print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
good = N
i = 0
A = [int(x) for x in input().split()]
A.sort(reverse=True)
for i in range(N):
    if A[i]==A[i-1] and i >= 1:
        good -= 1
        continue
    if A[i]==A[i+1]:
        good -= 1
        continue
    for j in range(i+1,N):
        if A[i]%A[N-j+i]==0:
            good -= 1
            break
print(good)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
# divlist = []

# 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]

if 1 in a:
    if a.count(1) > 1:
        print(0)
    else:
        print(1)
else:
    for i in range(0,n):
    for j in range(0,n):
        if i == j:
            continue
        else:
            if a[i] % a[j] == 0:
                count +=1
#     a.sort(reverse = True)
#     if len(set(a)) < len(a):
#         a = list(set(a))
#     if len(a) == 0:
#         print(0)
#         exit()
#     for i in range(0,len(a)):

#         divlist.append(make_divisors(a[i]))
    
#     print(15 in i for i in divlist)
print(count)

Submission status: Runtime Error

Solution code:
"""
    こんにちは。これはクシャルです
    
    Author : thekushalghosh (クシャル)
    Team   : CodeDiggers
 
    I prefer Python language over the C++ language :p :D
        
    Visit my website : thekushalghosh.github.io
"""
import sys,math,cmath,time
start_time = time.time()
##########################################################################
################# ---- THE ACTUAL CODE STARTS BELOW ---- #################
def qw(arr,n):
    s = dict()
    c = 0
    max_ele = -10**9
    for i in range(n):  
        s[arr[i]] = 1 
        max_ele = max(max_ele, arr[i])
    res = dict() 
    for i in range(n):  
        if (arr[i] != 0): 
            for j in range(arr[i] * 2,max_ele + 1, arr[i]):
                if (j in s.keys()): 
                    res[j] = 1
    q = []
    for x in res:
        c = c + 1
        q.append(x)
    return(c,q)

def solve():
    n = inp()
    a = inlt()
    a.sort()
    c,w = qw(list(set(a)),len(list(set(a))))
    w.sort()
    ww = []
    qq = 0
    if w:
        for i in range(len(a)):
            if a[i] != w[qq]:
                ww.append(a[i])
            elif qq + 1 < len(w):
                qq = qq + 1
    else:
        qw = list(a)
    q = counter(ww)
    print(len(list(set(a))) - c - len(q) + q.count(0) + q.count(1))
            
################## ---- THE ACTUAL CODE ENDS ABOVE ---- ##################
##########################################################################
 
def main():
    global tt
    if not ONLINE_JUDGE:
        sys.stdin = open("input.txt","r")
        sys.stdout = open("output.txt","w")
    t = 1
    for tt in range(t):
        solve()
    if not ONLINE_JUDGE:
        print("Time Elapsed :",time.time() - start_time,"seconds")
        sys.stdout.close()
    
#---------------------- USER DEFINED INPUT FUNCTIONS ----------------------#
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    return(input().strip())
def invr():
    return(map(int,input().split()))
 
#------------------ USER DEFINED PROGRAMMING FUNCTIONS ------------------#
def counter(a):
    q = [0] * (max(a) + 1)
    for i in range(len(a)):
        q[a[i]] = q[a[i]] + 1
    return(q)
 
def string_counter(a):
    q = [0] * 26
    for i in range(len(a)):
        q[ord(a[i]) - 97] = q[ord(a[i]) - 97] + 1
    return(q)

def power_two(n):
    if n == 1:
        return(True)
    sttr = str(n)
    len_str = len(sttr)
    sttr = list(sttr)
    num = 0
    if (len_str == 1 and sttr[len_str - 1] == '1'): 
        return(False)
    while (len_str != 1 or sttr[len_str - 1] != '1'):
        if ((ord(sttr[len_str - 1]) - ord('0')) % 2 == 1):
            return(False)
        j = 0; 
        for i in range(len_str):  
            num = num * 10 + (ord(sttr[i]) - ord('0')); 
            if (num < 2): 
                if (i != 0):  
                    sttr[j] = '0'
                    j += 1
                continue
  
            sttr[j] = chr((num // 2) + ord('0'))
            j += 1; 
            num = (num) - (num // 2) * 2
        len_str = j
    return(True)

def getLeftmostBit(n): 
    m = 0
    while (n > 1) : 
        n = n >> 1
        m += 1
    return(m)
def getNextLeftmostBit(n, m) : 
    temp = 1 << m 
    while (n < temp) : 
        temp = temp >> 1
        m -= 1
    return m
def bitcounter(n) :
    m = getLeftmostBit(n) 
    return _countSetBits(n, m) 
def _countSetBits(n, m) :
    if (n == 0) : 
        return 0
    m = getNextLeftmostBit(n, m)
    if (n == (1 << (m + 1)) - 1) : 
        return ((m + 1) * (1 << m))
    n = n - (1 << m)
    return (n + 1) + bitcounter(n) + m * (1 << (m - 1)) 

def log_two(n): 
    return(math.log(n) / math.log(2))

#-----------------------------------------------------------------------#
        
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
    input = sys.stdin.readline
    
main()

Submission status: Runtime Error

Solution code:
N = int(input1())
As = list(map(int, input().split(' ')))

not_divisible = 0
for num_i, Ai in enumerate(As):
    for num_j, Aj in enumerate(As):
        if num_i==num_j:
            continue
        if Ai%Aj==0:
            break
    else:
        not_divisible += 1
print(not_divisible)

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int,input().split()))
A = sorted(A,reverse=True)
ans = 0
for i in range(N):
    x = 0
    for j in range(i+1,N):
        if A[i] % A[j] == 0:
            x += 1
            break
    if x == 0:
        ans += 1
if A[-1] == A[-2]:
    ans -= 1
print(ans)

Submission status: Runtime Error

Solution code:
import sys

def ma_index(l,x,default=False):
    if x in l:
        return l.index(x)
    else:
        return default

N=int(input())
A=list(map(int,input().split()))

A.sort()
B=[0]*N

if 1 in A:
    if A.count(1)>1:
        print(0)
    else:
        print(1)
    sys.exit()

syote=0

if A[0]==A[1]:
    syote=1

for i in range(N-1):
    if A[i]==A[i+1]:
        B[i]+=1
        B[i+1]+=1


for i in range(N):
    if A[i]==0:
        continue
    a=A[i]
    b=a
    cnt=1
    while b<A[N-1]:
        cnt+=1
        b=a*cnt
        ind=ma_index(A,b)
        A[ind]=0
        B[ind]+=1

if syote==0:
    B[0]=0

print(B.count(0))

Submission status: Runtime Error

Solution code:
import copy
import numpy as np

n = int(input())
al = list(map(int, input().split()))

if len(set(al)) == 1:
    print(0)
    exit()

ary = np.array(al)

def divide(ar, i):
    new = ar%ar[i]
    ans = ar[new!=0]
    ans = np.append(ar[i], ans)
    return ans

j = 0
arra = ary
while True:
    if arra[j]*2 <= np.max(arra):
        arra = divide(arra, j)
        j += 1
    else:
        print(len(arra))
        break

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))

A.sort()
C=[]

while A[0] != "f,opwrkfrke":
    B =[]
    for n in range(1,len(A)):
        if A[n] % A[0] !=0:
            B.append(A[n])
        
    if A[0] != A[1]:
        
        C.append(A[0])
    print(A,B,C)
    A = B
    if len(A)==0:
        break
    Al = max(A)
    if A[0] == Al:
        C.append(B)
        break
#print(C)
if len(C)>0:
    print(len(C))
else:
    print(0)

Submission status: Runtime Error

Solution code:
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import deque
import pprint

inf = 10**18
mod = 10**9+7

n = int(input())
a = list(map(int, input().split()))
a.sort()
b = []
pre = a[0]
if a[0] != a[1]:
    if pre == 1:
        print(1)
        sys.exit()
else:
    if pre == 1:
        print(0)
        sys.exit()
c = collections.Counter(a)
for k,v in c.items():
    if v == 1:
        b.append(k)

judge = [False for i in range(10**6+1)]
for num in b:
    judge[num] = True
for i in range(1,(10**6)//2+1):
    if judge[i]:
        for j in range(i*2,10**6+1,i):
            judge[j] = False
ans = 0
for i in range(1,10**6+1):
    if judge[i]:
        ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
As = input().split()
A = []

for i in range(N):
    A.append(int(As[i]))

rA = sorted(A)

count = 0
dividable = False

if rA[0]%rA[1]!=0:
    count += 1

for i in range(1, N):
    for s in range(i):
        if rA[i]%rA[s] == 0:
            dividable = True
            break
    if dividable==False:
        count += 1
    else:
        dividable = False

print(count)