Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

MOD = 10 ** 9 + 7


def prepare(n):
    global MOD
    modFacts = [0] * (n + 1)
    modFacts[0] = 1
    for i in range(n):
        modFacts[i + 1] = (modFacts[i] * (i + 1)) % MOD

    invs = [1] * (n + 1)
    invs[n] = pow(modFacts[n], MOD - 2, MOD)
    for i in range(n, 1, -1):
        invs[i - 1] = (invs[i] * i) % MOD

    return modFacts, invs


N, K = map(int, input().split())
A = list(map(int, input().split()))
modFacts, invs = prepare(N)


# mod2 = [0] * (N + 1)
# mod2[0] = 1
# for i in range(N):
#     mod2[i + 1] = mod2[i] * 2
#     mod2[i + 1] %= MOD

A.sort()
ans = 0
for i in range(N):
    for j in range(K - 1, N - i):
        x = A[i + j]
        y = A[i]
        ans += (x - y) * modFacts[j - 1] * invs[j - 1 - (K - 2)] * invs[K - 2]
        ans %= MOD

print(ans)


### FIXED CODE ###

MOD = 10 ** 9 + 7


def prepare(n):
    global MOD
    modFacts = [0] * (n + 1)
    modFacts[0] = 1
    for i in range(n):
        modFacts[i + 1] = (modFacts[i] * (i + 1)) % MOD

    invs = [1] * (n + 1)
    invs[n] = pow(modFacts[n], MOD - 2, MOD)
    for i in range(n, 1, -1):
        invs[i - 1] = (invs[i] * i) % MOD

    return modFacts, invs


N, K = map(int, input().split())
A = list(map(int, input().split()))
modFacts, invs = prepare(N)


# mod2 = [0] * (N + 1)
# mod2[0] = 1
# for i in range(N):
#     mod2[i + 1] = mod2[i] * 2
#     mod2[i + 1] %= MOD

A.sort()
ans = 0

for i in range(K - 1, N):
    n = i
    r = K - 1
    num = (modFacts[n] * invs[n - r] * invs[r]) % MOD
    ans += A[i] * num
    ans %= MOD

for i in range(N - K + 1):
    n = N - (i + 1)
    r = K - 1
    num = (modFacts[n] * invs[n - r] * invs[r]) % MOD
    ans -= A[i] * num
    ans %= MOD


print(ans)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**8)

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

d = {}


def func(b, m):
    if m == 0:
        return 0
    if m == 1:
        return b[0]
    if m == 2:
        return max(b[0], b[1])
    if m in d:
        return d[m]

    if m % 2 == 0:
        ans0 = b[0] + func(b[2:], m - 2)
        ans1 = sum(b[i] for i in range(1, m, 2))
        ans = max(ans0, ans1)
    else:
        ans0 = b[0] + func(b[2:], m - 2)
        ans1 = b[1] + func(b[3:], m - 3)
        ans2 = sum(b[i] for i in range(2, m, 2))
        ans = max(ans0, ans1, ans2)

    d[m] = ans
    return ans


ans = func(a, n)

print(ans)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**8)

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

a_cs = [0] * (n + 1)
a_cs[-2] = a[-1]
for i in reversed(range(n - 1)):
    a_cs[i] = a[i] + a_cs[i + 2]
# print(a_cs)

d = {}


def func(i):
    if i == n:
        return 0
    if i == n - 1:
        return a[-1]
    if i in d:
        return d[i]

    m = n - i
    if m % 2 == 0:
        ans0 = a[i] + func(i + 2)
        ans1 = a_cs[i + 1]
        ans = max(ans0, ans1)
    else:
        ans0 = a[i + 0] + func(i + 2)
        ans1 = a[i + 1] + func(i + 3)
        ans2 = a_cs[i + 2]
        ans = max(ans0, ans1, ans2)

    d[i] = ans
    return ans


ans = func(0)

print(ans)
### BUGGY CODE ###

n,m=map(int,input().split())
a=[int(input()) for _ in range(m)]
dp=[0]*(n+2)
dp[0]=1
for i in range(n):
    if i in a:
        continue
    dp[i+1]+=dp[i]
    dp[i+2]+=dp[i]
print(dp[n]%1000000007)

### FIXED CODE ###

n,m=map(int,input().split())
a=set(int(input()) for _ in range(m))
dp=[0]*(n+2)
dp[0]=1
for i in range(n):
    if i in a:
        continue
    dp[i+1]+=dp[i]
    dp[i+2]+=dp[i]
print(dp[n]%1000000007)
### BUGGY CODE ###

def resolve():
	from collections import deque
	N, M, Q = map(int, input().split())
	A = [list(map(int, input().split())) for i in range(Q)]
	
	def calc(x): # type(x) == str型
		ans = 0
		for a, b, c, d in A:
			if int(x[b-1]) - int(x[a-1]) == c:
				ans += d
		return ans
		
	q = deque([1])
	ans = 0
	while q:
		tmp = q.popleft()
		tmp = str(tmp)
		if len(tmp) == N:
			ans = max(ans, calc(tmp))
		else:
			for i in range(int(tmp[-1]), M+1):
				q.append(tmp+str(i))

	print(ans)
	
resolve()


### FIXED CODE ###

from collections import deque


# 数列の点数を計算する関数
def calc(seq):
    score = 0
    for a, b, c, d in req:
        if seq[b - 1] - seq[a - 1] == c:
            score += d

    return score


n, m, q = list(map(int, input().split()))
req = [list(map(int, input().split())) for _ in range(q)]

ans = 0

que = deque()

# 数列の1番目、[1]～[m]までキューに追加しますが、
# 実は、この問題は数列の最初が[1]の場合だけを考えても解けます。
for i in range(1, m + 1):
    que.append([i])

while que:
    seq = que.popleft()

    if len(seq) == n:
        # 長さがnになったので、得点を計算します
        score = calc(seq)
        ans = max(ans, score)
    else:
        # 次に追加する数字は、下限が今の数列の一番後ろの数字、上限がmです
        for i in range(seq[-1], m + 1):
            seq_next = seq + [i]
            que.append(seq_next)

print(ans)
### BUGGY CODE ###

def main():
    n = int(input())

    def q(i):
        print(i, )
        s = str(input())
        if s == 'Vacant':
            exit()
        else:
            return s

    x = q(0)

    def ok(m):
        if m == 0:
            return False
        else:
            if (m%2 == 0 and q(m) != x) or (m%2 == 1 and q(m) == x):
                return True
            else:
                return False

    l = 0
    r = n-1
    while l+1 < r:
        c = (l+r)//2
        if ok(c):
            r = c
        else:
            l = c

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    n = int(input())

    def q(i):
        print(i, )
        s = str(input())
        if s == 'Vacant':
            exit()
        else:
            return s

    x = q(n-1)
    x = q(0)

    def ok(m):
        if m == 0:
            return False
        else:
            if (m%2 == 0 and q(m) != x) or (m%2 == 1 and q(m) == x):
                return True
            else:
                return False

    l = 0
    r = n-1
    while l+1 < r:
        c = (l+r)//2
        if ok(c):
            r = c
        else:
            l = c

if __name__ == '__main__':
    main()
### BUGGY CODE ###

from itertools import combinations

def main():
    n=int(input())
    a=list(map(int,input().split()))
    ans=0
    mod=10**9+7
    for i,j in combinations(a, 2):
        ans += i*j
        ans %= mod
    print(ans)

if __name__ == '__main__':
    main()

### FIXED CODE ###

from itertools import accumulate
def main():
    mod=10**9+7
    n=int(input())
    a=list(map(int,input().split()))
    aa=[0]+list(accumulate(a))
    ans=0
    for i in range(n-1):
        ans += a[i]*(aa[-1]-aa[i+1])%mod
    print(ans%mod)

if __name__ == '__main__':
    main()
### BUGGY CODE ###

k=0
s=0
combi = 0

def nyu():
    num1,num2 = input().split()
    k = int(num1)
    s = int(num2)
    return k,s

def calc(l_k,l_s):
    l_combi = 0
    for x in range(l_k):
        for y in range(l_k):
            if check1(x,y,l_s) == True :
               break
            for z in range(l_k):
                if check2(x,y,z,l_s) == True :
                    break
        #        print("x=",x,"y=",y,"z=",z)
                sum = x+y+z
                if l_s == sum:
                    l_combi +=1
                    
    return l_combi

def check1(x,y,s):
    sum = x+y
    if s<sum:
        return True
    return False

def check2(x,y,z,s):
    sum = x+y+z
    if s<sum:
        return True
    return False    









    

    



k,s=nyu()
print(calc(k+1,s))









### FIXED CODE ###

k=0
s=0
combi = 0

def nyu():
    num1,num2 = input().split()
    k = int(num1)
    s = int(num2)
    return k,s

def calc(l_k,l_s):
    l_combi = 0
    for x in range(l_k):
#        check_tmp =0
#        check_tmp =check1(x,l_s,l_k)
#        if check_tmp == 1:
#            break
#        elif check_tmp  == 2:
#            continue
        for y in range(l_k):
#            check_tmp =check2(x,y,l_s,l_k)
#            if check_tmp == 1:
#                break
#            elif check_tmp  == 2:
#                continue2
#            sum = x+y+l_k 
            sum = l_s- x-y 
            if 0<=sum and sum <= k:
#                print("x=",x,"y="   ,y) 
                l_combi +=1
    return l_combi

def check1(x,s,k):
    if s<x:
        return 1
    if x+(k-1)*2 < s:
        return 2
    return 0

def check2(x,y,s,k):
    sum = x+y
    if s<sum:
        return 1
    if x+y+k-1 < s:
       return 2
    return 0

def check3(x,y,z,s):
    sum = x+y+z
    if s<sum:
        return 1
    return 0    

def check_ini(k,s):
    if k*3 < s:
        return True
    return False


k,s=nyu()
if check_ini == True:
    print("0")
else :
    print(calc(k+1,s))
### BUGGY CODE ###

#coding: UTF-8

prime_number_list = []

def is_prime(target_num):
    if target_num in prime_number_list:
        return True
    i = 2
    while i * i <= target_num:
        if target_num % i == 0:
            return False
        i += 1
    return True

def count_prime_numbers(target_num_list):
    prime_count = 0
    counted_num = 0
    prime_count_map = {}
    for i in range(2, target_num_list[len(target_num_list) - 1] + 1):
        if is_prime(i):
            prime_number_list.append(i)
            prime_count += 1
        if i >= target_num_list[counted_num]:
            prime_count_map[target_num_list[counted_num]] = prime_count
            counted_num += 1
    return prime_count_map

input_list = []
sorted_input_list = []
while True:
    try:
        input_str = raw_input()
    except EOFError:
        break
    input_list.append(int(input_str))
    sorted_input_list.append(int(input_str))

sorted_input_list.sort()

prime_counts = count_prime_numbers(sorted_input_list)

for i in input_list:
    print prime_counts[i]

### FIXED CODE ###

max_n = 999999
prime_list = [1] * (max_n + 1)

# 0, 1は素数ではない
prime_list[0:2] = [0, 0]

# 
for i in range(2, int(max_n**0.5) + 1):
    if prime_list[i] == 1:
        prime_list[i**2::i] = [0] * len(prime_list[i**2::i])

while True:
    try:
        n = int(input())
        print(sum(prime_list[:n + 1]))

    except EOFError:
        break
### BUGGY CODE ###

import math

class Input():
	def readInt(self):
		return int(input())

	def readIntArray(self):
		return [int(x) for x in input().split(" ")]

	def readString(self):
		return input()

	def readStringArray(self):
		return input().split(" ")

	def readFloat(self):
		return float(input())

	def readFloatArray(self):
		return [float(x) for x in input().split(" ")]

def main():
	inp = Input()
	n, k = inp.readIntArray()
	height = inp.readIntArray()

	cost = [1000000002 for i in range(n)]
	cost[0] = 0

	for i in range(n):
		for j in range(1, k+1):
			if (i + j) < n:
				cost[i+j] = min(cost[i+j], cost[i] + abs(height[i+j] - height[i]))

	print(cost[n-1])
	

if __name__ == "__main__":
   main()


### FIXED CODE ###

def main():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    a = [0] * n
    a[0] = 0
    for i in range(1, n):
        a[i] = min([a[j] + abs(h[i] - h[j]) for j in range(max(0, i - k), i)])
    print(a[-1])
 
if __name__ == '__main__':
    main()
### BUGGY CODE ###

import math
a,b=map(int,input().split())
c=[list(map(int,input().split())) for i in range(a-1)]
d=[[]for i in range(a)]
for i in range(a-1):
  ca=c[i][0]
  cb=c[i][1]
  d[ca-1].append(cb-1)
  d[cb-1].append(ca-1)
g=[0 for i in range(a)]
q=[0]
e=b
while not q==[]:
  i=q[-1]
  f=1
  h=len(d[i])
  if g[i]==0:
    if i==0:
      for j in range(h):
        f=f*(b-1-j)
    else:
      if h>0:
        for j in range(h-1):
          f=f*(b-2-j)
  e=(e*f)%1000000007
  k=0
  g[i]=1
  for j in range(h):
    if g[d[i][j]]==0:
      q.append(d[i][j])
      k=1
      break
  if k==0:
    q.pop()


print(e%1000000007)
  

### FIXED CODE ###

from collections import deque
a,b=map(int,input().split())
c=[list(map(int,input().split())) for i in range(a-1)]
d=[[]for i in range(a)]
for i in range(a-1):
  ca=c[i][0]
  cb=c[i][1]
  d[ca-1].append(cb-1)
  d[cb-1].append(ca-1)
g=[0 for i in range(a)]
q=deque()
q.append(0)
e=b
while len(q):
  i=q.pop()
  h=len(d[i])
  g[i]=1
  if i==0:
      f=b-1
  else:
    f=b-2
  g[i]=1
  for j in range(h):
    if g[d[i][j]]==0:
      q.append(d[i][j])
      e=(e*f)%1000000007
      f-=1


print(e%1000000007)
### BUGGY CODE ###

N, K = map(int, input().split())
A = list(map(int, input().split()))
A = sorted(A)
B = A[:][::-1]

def ncr(n, r, p):
  num = den = 1
  for i in range(r):
    num = (num * (n - i)) % p
    den = (den * (i + 1)) % p
  return (num * pow(den, p - 2, p)) % p
p=10**9+7

ans = 0
for i in range(K-1, N):
  ans += A[i] * ncr(i, K-1, p)
  ans %= p 
for i in range(K-1, N):
  ans -= B[i] * ncr(i, K-1, p)
  ans %= p
print(ans)


### FIXED CODE ###

N, K = map(int, input().split())
A = list(map(int, input().split()))
A = sorted(A)
B = A[:][::-1]

fac = [1, 1]
finv = [1, 1]
inv = [0, 1]
Mod = 10**9+7
def COMinit():
  #N_C_kのN
  for i in range(2, 10**5+10):
    fac.append(fac[-1]*i%Mod)
    inv.append((-inv[Mod%i] * (Mod//i)) % Mod)
    finv.append(finv[-1] * inv[-1] % Mod)


def COM(n, k):
  if n < 0 or k < 0 or n < k:
    return 0
  return fac[n] * (finv[k] * finv[n-k] % Mod) % Mod

COMinit()

comb = {}
for i in range(K-1, N):
  comb[(i, K-1)] = COM(i, K-1)

ans = 0
for i in range(K-1, N):
  ans += A[i] * comb[(i, K-1)]
  ans %= Mod
for i in range(K-1, N):
  ans -= B[i] * comb[(i, K-1)]
  ans %= Mod
print(ans)
### BUGGY CODE ###

from sys import exit, stderr, stdin, setrecursionlimit
input = stdin.readline
setrecursionlimit(10**7)
def debug(var, name="hoge"):
    print(name +":" + str(type(var)) + " = " + repr(var), file=stderr)
    return




MOD = 10**9+7
NUM = 10**5 + 2

fact = [1] * (NUM + 1)
fact_inv = [1] * (NUM + 1)

for i in range(1, NUM+1):
    fact[i] = (fact[i-1]*i) % MOD
# フェルマーの少定理から(a**MOD-1)が1 => (a**MOD-2)がaの逆元
fact_inv[NUM] = pow(fact[NUM], MOD-2, MOD)

# 階乗の逆元は、逆元の階乗なので、(n-1)!の逆元を求めたいなら(n!の逆元)*nでOK
for i in range(NUM, 2, -1):
    fact_inv[i-1] = (fact_inv[i]*i) % MOD

def perm(n,k):
    if n<k or k<0:
        return 0
    else:
        return (fact[n]*fact_inv[n-k])% MOD



def main():
    N, K = map(int,input().split())

    adjl = [[] for _ in range(N)]
    for _ in range(N-1):
        a ,b = map(int,input().split())
        a ,b = a-1, b-1
        adjl[a].append(b)
        adjl[b].append(a)
    deg = [len(n) for n in adjl]

    def count(n, parent = None):
        # ルートなら親を含めたその子の塗り方
        if parent is None:
            c = perm(K,deg[n]+1)
        # それ以外なら自分と親が決まってるので子の塗り方
        else:
            c = perm(K-2,deg[n]-1)
        for neigh in adjl[n]:
            if neigh == parent:
                continue
            c *= count(neigh,n)
            c %= MOD
        return c
    print(count(0))





if __name__ == "__main__":
    main()


### FIXED CODE ###

from sys import exit, stderr, stdin, setrecursionlimit
input = stdin.readline
setrecursionlimit(10**7)
def debug(var, name="hoge"):
    print(name +":" + str(type(var)) + " = " + repr(var), file=stderr)
    return




MOD = 10**9+7
NUM = 10**5 + 2

fact = [1] * (NUM + 1)
fact_inv = [1] * (NUM + 1)

for i in range(1, NUM+1):
    fact[i] = (fact[i-1]*i) % MOD
# フェルマーの少定理から(a**MOD-1)が1 => (a**MOD-2)がaの逆元
fact_inv[NUM] = pow(fact[NUM], MOD-2, MOD)

# 階乗の逆元は、逆元の階乗なので、(n-1)!の逆元を求めたいなら(n!の逆元)*nでOK
for i in range(NUM, 2, -1):
    fact_inv[i-1] = (fact_inv[i]*i) % MOD

def perm(n,k):
    if n<k or k<0:
        return 0
    else:
        return (fact[n]*fact_inv[n-k])% MOD



def main():
    N, K = map(int,input().split())

    adjl = [[] for _ in range(N)]
    for _ in range(N-1):
        a ,b = map(int,input().split())
        a ,b = a-1, b-1
        adjl[a].append(b)
        adjl[b].append(a)
    deg = [len(n) for n in adjl]

    def count(n, parent = None):
        # ルートなら親を含めたその子の塗り方
        if parent is None:
            c = perm(K,deg[n]+1)
        # それ以外なら自分と親が決まってるので子の塗り方
        else:
            c = perm(K-2,deg[n]-1)
        for neigh in adjl[n]:
            if neigh == parent:
                continue
            c *= count(neigh,n)
            c %= MOD
        return c
    print(count(0))





if __name__ == "__main__":
    main()
### BUGGY CODE ###

n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [0] * n
for i in range(1, n):
    hi=h[i]
    dp[i] = min(dp[ii] + abs(hi - h[ii]) for ii in range(max(0, i - k), i))
print(dp[-1])


### FIXED CODE ###

n, k = map(int, input().split())
k = min(n - 1, k)
h = list(map(int, input().split()))
cost = [0 for _ in range(n)]
for i, hi in enumerate(h):
    if i == 0: continue
    st = i - k if i > k else 0
    cost[i] = min([ck + abs(hi - hk) for ck, hk in zip(cost[st:i], h[st:i])])
print(cost[-1])
### BUGGY CODE ###

import sys
input=sys.stdin.readline  #危険！基本オフにしろ！

def main():
    n,k=map(int,input().split())
    a=sorted(map(int,input().split()))
    b=sorted(map(int,input().split()),reverse=1)
    #print(a,b)
    ok=max(a)*max(b)
    ng=-1
    
    
            
    while abs(ok-ng)>1:
        mid=(ok+ng)//2
        if sum(a[i]-mid//b[i]for i in range(n) if a[i]*b[i]>mid)<=k:
            ok=mid
        else:
            ng=mid
    print(ok)

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
input=sys.stdin.readline  #危険！基本オフにしろ！
 
def main():
    n,k=map(int,input().split())
    a=sorted(map(int,input().split()))
    b=sorted(map(int,input().split()),reverse=1)
    #print(a,b)
    ok=max(a)*max(b)
    ng=-1
    
    def check(a,b,mid,k):
        if sum(a[i]-mid//b[i]for i in range(n) if a[i]*b[i]>mid)<=k:
            return 1
        else:
            return 0
            
    while abs(ok-ng)>1:
        mid=(ok+ng)//2
        if check(a,b,mid,k):
            ok=mid
        else:
            ng=mid
    print(ok)

if __name__ == '__main__':
    main()
### BUGGY CODE ###

R,C,K = map(int, input().split())

maze = [[0 for _ in range(C)] for _ in range(R)]
dp = [[[0 for _ in range(C+1)] for _ in range(R+1)] for _ in range(4)]
for i in range(K):
    r,c,v = map(int, input().split())
    r -=1
    c -= 1
    maze[r][c] = v

for i in range(R):
    for j in range(C):
        
        for k in range(2, -1, -1):
            dp[k+1][i][j] = max(dp[k+1][i][j], dp[k][i][j] + maze[i][j])

        for k in range(4):
            dp[0][i+1][j] = max(dp[0][i+1][j], dp[k][i][j])
            dp[k][i][j+1] = max(dp[k][i][j+1], dp[k][i][j])  

ans = 0

for k in range(4):
    ans = max(ans, dp[k][R-1][C-1])       

print(ans)

### FIXED CODE ###

R,C,K = map(int, input().split())

d = [[0 for _ in range(C+1)] for _ in range(R+1)]
dp = [[[0 for _ in range(C+1)] for _ in range(R+1)] for _ in range(4)]

for i in range(K):
    r, c, v = map(int, input().split())
    d[r-1][c-1] = v
for i in range(R):
    for j in range(C):
        # kが大きい方からやらないとダメ。01ナップサックと同じ考え方。書き換えられた値を見ないように。
        for k in range(2, -1, -1):
            # 拾う遷移。d[i][j]を取るかどうかという判定
            dp[k+1][i][j] = max(dp[k+1][i][j], dp[k][i][j] + d[i][j])
        for k in range(4):
            dp[0][i+1][j] = max(dp[0][i+1][j], dp[k][i][j])
            dp[k][i][j+1] = max(dp[k][i][j+1], dp[k][i][j])
ans = 0

for k in range(4):
    ans = max(ans, dp[k][R-1][C-1])
print(ans)
### BUGGY CODE ###

n = int(input())
text = []
for i in range(n):
  s = input()
  if s not in text:
    text.append(s)
print(len(text))

### FIXED CODE ###

import collections

n = int(input())
text = []
for i in range(n):
  s = input()
  text.append(s)
print(len(collections.Counter(text)))
### BUGGY CODE ###

def solve():
    for i in range(len(arr)):
        if arr[i] == b:
            arr[i] = c
    return sum(arr)

if __name__ == '__main__':
    n = int(input())
    arr = list(map(int, input().split()))
    q = int(input())
    for i in range(q):
        b, c, = map(int, input().split())
        print(solve())

### FIXED CODE ###

if __name__ == '__main__':
    n = int(input())
    arr = list(map(int, input().split()))
    d = {}
    for i in range(len(arr)):
        if arr[i] in d:
            d[arr[i]] += 1
        else:
            d[arr[i]] = 1
    sums = sum(arr)
    q = int(input())
    for i in range(q):
        b, c = map(int, input().split())
        if b in d:
            sums -= (b * d[b])
            sums += (c * d[b])
        if c not in d and b in d:
            d[c] = d[b]
        elif b in d:
            d[c] += d[b]
        if b in d:
            d[b] = 0
        print(sums)
### BUGGY CODE ###

from collections import Counter

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

def main():
    n = int(input())
    A = list(map(int, input().split()))
    s = set(A)
    c = Counter(A)
    cnt = 0
    for a in A:
        if c[a] >= 2:
            continue
        else:
            d = set(div(a))
            if len(d - s) == len(d) - 1:
                cnt += 1
    print(cnt)
main()

### FIXED CODE ###

from collections import Counter
n = int(input())
A = sorted(map(int, input().split()))
M = A[-1]
c = Counter(A)
s = set()
ans = 0
for a in A:
    if a in s:
        continue
    if c[a] == 1:
        ans += 1
    i = 1
    while a * i <= M:
        s.add(a * i)
        i += 1
print(ans)
### BUGGY CODE ###

# -*- coding: utf-8 -*-

X, Y, Z, K = map(int, input().split())
# A = sorted(map(int, input().split()), reverse=True)
# B = sorted(map(int, input().split()), reverse=True)
# C = sorted(map(int, input().split()), reverse=True)
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

AB = []

for a in A:
    for b in B:
        AB.append(a + b)

AB = sorted(AB, reverse=True)

if K < len(AB):
    AB = AB[:K]

ABC = []
for ab in AB:
    for c in C:
        ABC.append(ab + c)

ABC = sorted(ABC, reverse=True)

ABC = ABC[:K]
ABC = [str(abc) for abc in ABC]

print("\n".join(ABC))


### FIXED CODE ###

# -*- coding: utf-8 -*-

X, Y, Z, K = map(int, input().split())
A = sorted(map(int, input().split()), reverse=True)
B = sorted(map(int, input().split()), reverse=True)
C = sorted(map(int, input().split()), reverse=True)

ABC = []

for x in range(X):
    for y in range(Y):
        if (x + 1) * (y + 1) > K:
            break
        for z in range(Z):
            if (x + 1) * (y + 1) * (z + 1) > K:
                break
            ABC.append(A[x] + B[y] + C[z])

ABC = sorted(ABC, reverse=True)

ABC = ABC[:K]
ABC = [str(abc) for abc in ABC]

print("\n".join(ABC))
### BUGGY CODE ###

import sys
sys.setrecursionlimit(1000000)
N,Q = map(int,input().split())
T = [[] for i in range(N+1)]
V = [0]*(N+1)
for _ in range(N-1):
    a,b = map(int,input().split())
    T[a].append(b)
    T[b].append(a)
for _ in range(Q):
    p,x = map(int,input().split())
    V[p]+=x
def f(v,p,s):
    global T,V
    V[v] = s
    for c in T[v]:
        if c==p:continue
        f(c,v,s+V[c])
f(1,0,V[1])
print(*V[1:])

### FIXED CODE ###

N,Q = map(int,input().split())
T = [0]*(N+1)
V = [0]*(N+1)
for _ in range(N-1):
    a,b = map(int,input().split())
    T[b] = a
for _ in range(Q):
    p,x = map(int,input().split())
    V[p]+=x
for i in range(1,N+1):
    V[i]+=V[T[i]]
print(*V[1:])
### BUGGY CODE ###

def calc_sub(m):
  return m-1

n,k,q = map(int, input().split())

point_l = [k] * n

for _ in range(q):
  point_l = list(map(calc_sub, point_l))
  ans = int(input())
  point_l[ans-1] += 1

for i in range(n):
  if point_l[i] <= 0:
    print('No')
  else:
    print('Yes')

### FIXED CODE ###

n,k,q = map(int, input().split())


point_l = [k-q] * n
for _ in range(q):
 ans = int(input())
 point_l[ans-1] += 1

for i in range(n):
  print('Yes' if point_l[i]>0 else 'No')