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

N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for i in range(M)]
#print(N,M)
#print(A)
#print(BC)
#print("---")
times = [bc[0] for bc in BC]
values = [bc[1] for bc in BC]
values, times = zip(*sorted(zip(values, times),reverse=True))
#print(values)
#print(times)
#values.sort(reverse=True)
for i, v in enumerate(values) :
    for t in range(times[i]) :
        min_A = min(A)
        if v > min_A :
            A[A.index(min(A))] = v
            #print(A)
        else :
            break
    else:
        continue
    break
print(sum(A))





### FIXED CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for i in range(M)]
#print(N,M)
#print(A)
#print(BC)
#print("---")
A = sorted(A)
BC = sorted(BC, key = lambda x: -x[1])
D = []
for bc in BC :
    for i in range(bc[0]) :
        if len(D) < N :
            D.append(bc[1])
        else :
            break
    else :
        continue
    break
if N > len(D) :
    S = len(D)
else :
    S = N
for i in range(S) :
    if A[i] < D[i] :
        A[i] = D[i]
    else :
        break
print(sum(A))

#times = [bc[0] for bc in BC]
#values = [bc[1] for bc in BC]
#values, times = zip(*sorted(zip(values, times),reverse=True))
#print(values)
#print(times)
#values.sort(reverse=True)


# for i, v in enumerate(values) :
#     tmp = [n for n,i in enumerate(A) if i > v]
#     if len(tmp) == N :
#         break
#     elif len(tmp) == 0 :
#         ind = N + 1
#     else :
#         ind = tmp[0]
#
#     if times[i] < ind :
#         A[0:times[i]] = [v] * times[i]
#     else :
#         A[0:ind] = [v] * ind
#     #print(A)
#     A = sorted(A)
# print(sum(A))

#for i, v in enumerate(values) :
#    for t in range(times[i]) :
#        min_A = min(A)
#        if v > min_A :
#            A[A.index(min(A))] = v
#            print(A)
#        else :
#            break
#    else:
#        continue
#    break
#print(sum(A))
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
ans = 0
for a in A:
    ans ^= a 
M = 2**60-1
b = M^ans
for i in range(N):
    A[i] &= b
A.sort(reverse=True)
for i in range(min(60,N)):
    a = A[i]
    if a == 0:
        break
    l = len(bin(a))
    for j in range(N):
        if j==i:
            continue
        if l==len(bin(A[j]%2**(l-2))):
            A[j] ^= a
        else:
            if i < j:
                break
    A.sort(reverse=True)
s = 0
for a in A:
    s ^= a
ans += 2*s
print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
ans = 0
for a in A:
    ans ^= a
M = 2**60-1
b = M^ans
for i in range(N):
    A[i] &= b
A.sort(reverse=True)
for i in range(min(60,N)):
    a = A[i]
    if a == 0:
        break
    l = len(bin(a))-3
    for j in range(N):
        if j==i:
            continue
        if A[j]//2**l%2==1:
            A[j] ^= a
        else:
            if i < j:
                break
    A.sort(reverse=True)
s = 0
for a in A:
    s ^= a
ans += 2*s
print(ans)
### BUGGY CODE ###

from operator import itemgetter

 # print(sorted(a, key=itemgetter(1)))
N,M = map(int,input().split())

#Aは小さい順に並べる
A_list = list(map(int,input().split()))
A_list = sorted(A_list)
BC_list = []

ans = 0
idx = 0

for i in range(M):
    bi,ci = map(int,input().split())
    BC_list.append([bi,ci])

#BC_listからCの配列(長さはN)を作成する(大きい順)
C_list=[]
BC_list = sorted(BC_list,reverse=True,key=itemgetter(1))
for i in range(M):
    for j in range(BC_list[i][0]):
        C_list.append(BC_list[i][1])

#NにたりないばあいはNまで0で埋める、Nより大きい場合はNまでを使う
if len(C_list) > N:
    C_list = C_list[0:N]
else:
    for i in range(N-len(C_list)):
        C_list.append(1)

#どこの添字からAとCが逆転するか調べる
for i in range(N):
    #Aは昇順、Cは降順
    if C_list[i] > A_list[i]:
        A_list[i] = C_list[i]


print(sum(A_list))


### FIXED CODE ###


#AのリストにCのリストを加えて大きい順に並べ替えてNまでの和を求める
N,M = map(int,input().split())

#Aの入力
A_list = list(map(int,input().split()))

C_list = []

#Cのリストに追加する
for i in range(M):
    bi,ci = map(int,input().split())
    C_list.append([bi,ci])

#C_listをCの値でソート
C_list=sorted(C_list, reverse=True, key=lambda x:x[1])

count = 0
for bi,ci in C_list:
    count += bi
    if count > N:
        #countがNより大きくなったらNより大きくなった分だけ使う
        bi = N - count + bi
    A_list.extend([ci]*bi)

#A_Listを大きい順に並べ替える
A_list=sorted(A_list,reverse=True)

#N番目までの総和を求める
print(sum(A_list[0:N]))
### BUGGY CODE ###

N=int(input())
S = [input() for i in range(N)]
P=[]
P0=[]
A=[]
for i in range(len(S)):
    c=S.count(S[i])
    P0.append(c)
    if i==0:
        P.append(c)
    elif P[-1] < c:
        P.append(c)

for k in range(len(P0)):
    if P0[k]==P[-1]:
        A.append(S[k])

A0=set(A)
A1=list(A0)
A1.sort()

for List in A1:
    print(List)

### FIXED CODE ###

import collections
N=int(input())
S = [input() for i in range(N)]
A=[]

P=collections.Counter(S)

y=max(P.values())
A = [k for k, v in P.items() if v == y]

A.sort()

for List in A:
    print(List)
### BUGGY CODE ###

import fractions
from functools import reduce

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

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

MOD = 10**9+7
lcm_val = lcm_list(A)
diff = [lcm_val // a for a in A]
print(sum(diff)%MOD)


### FIXED CODE ###

class PrimeOptimizer:
    def __init__(self, MAX_NUM=10**3):
        is_prime = [True] * MAX_NUM
        is_prime[0] = False
        is_prime[1] = False
        primes = []
        for i in range(MAX_NUM):
            if is_prime[i]:
                primes.append(i)
                for j in range(2*i, MAX_NUM, i):
                    is_prime[j] = False
        self.primes = primes

    def prime_factorization(self, x):
        res = {}
        for prime in self.primes:
            while x % prime == 0:
                if not prime in res:
                    res[prime] = 0
                res[prime] += 1
                x //= prime
        if x > 1:
            res[x] = 1
        return res

MOD = 10**9+7

def mod_pow(p, q):
    res = 1
    while q:
        if q & 1:
            res = (res * p) % MOD
        p = (p * p) % MOD
        q //= 2
    return res

def mod_inv(p):
    return mod_pow(p, MOD - 2)

def solve(n, a):
    primeOpt = PrimeOptimizer()
    D = {}
    for i in range(n):
        prime_num_mapping = primeOpt.prime_factorization(a[i])
        for prime, num in prime_num_mapping.items():
            if not prime in D:
                D[prime] = 0
            D[prime] = max(D[prime], num)
    L = 1
    for prime, num in D.items():
        L = (L * mod_pow(prime, num)) % MOD
    res = sum([L * mod_inv(x) % MOD for x in a])
    return res % MOD

N = int(input())
A = list(map(int, input().split()))
print(solve(N, A))
### BUGGY CODE ###

n = int(input())
num = []
for i in range(n):
    a = int(input())
    num.append(a)

max_n = max(num)

for i in range(n):
    b = num[i]
    if b == max_n:
        num_c = num
        c = num_c[i]
        num_c[i] = 0
        print(max(num_c))
        num_c[i] = c
    else:
        print(max_n)

### FIXED CODE ###

n = int(input())
num = []
for i in range(n):
    a = int(input())
    num.append(a)

idx = num.index(max(num))
max_a = max(num)

num_c = num
num_c[idx] = 0
idx_2 = num_c.index(max(num_c))
max_a2 = max(num_c)

for i in range(n):
    if i == idx:
        print(max_a2)
    else:
        print(max_a)
### BUGGY CODE ###

N,S = map(int, input().split())
A = [int(a) for a in input().split()]
mod = 998244353

dp = [[0]*(S+1) for _ in range(N+1)]
#dp[i][j]:集合{A[k]|k=0,1,,,i}の部分集合の部分集合のうち、要素の総和がjになるものの個数
dp[0][0] = 1
for i in range(N):
    for j in range(S+1):
        dp[i+1][j] += 2*dp[i][j] #A[i]を使わない場合、集合{A[k]|k=0,1,,,i}の部分集合の数が2倍だけ増える
        dp[i+1][j] %= mod
        if j+A[i] <= S:
            dp[i+1][j+A[i]] += dp[i][j] #A[i]を使う場合、総和がjになる部分集合にA[i]を足せばよいので、個数はdp[i][j]だけ増える
            dp[i+1][j+A[i]] %= mod

print(dp[N][S])

### FIXED CODE ###

N,S = map(int, input().split())
A = [int(a) for a in input().split()]
mod = 998244353

dp = [[0]*(S+1) for _ in range(N+1)]
#dp[i][j]:集合{A[k]|k=0,1,,,i}の部分集合の部分集合のうち、要素の総和がjになるものの個数
dp[0][0] = 1
for i in range(N):
    for j in range(S+1):
        dp[i+1][j] += 2*dp[i][j] #A[i]を使わない場合、集合{A[k]|k=0,1,,,i}の部分集合の数が2倍だけ増える
        dp[i+1][j] %= mod
        if j+A[i] <= S:
            dp[i+1][j+A[i]] += dp[i][j] #A[i]を使う場合、総和がjになる部分集合にA[i]を足せばよいので、個数はdp[i][j]だけ増える
            dp[i+1][j+A[i]] %= mod

print(dp[N][S])
### BUGGY CODE ###

num, capacity = list(map(int, input().split()))
dp = [[0 for i in range(capacity + 1)] for j in range(num + 1)]

for i in range(1, num + 1):
    weight, value = list(map(int, input().split()))
    for w in range(capacity + 1):
        if w - weight >= 0:
            dp[i][w] = max( dp[i-1][w - weight] + value,  dp[i-1][w] )
        else:
            dp[i][w] = dp[i-1][w]
print(dp[num][capacity])

### FIXED CODE ###

def calc(num,capacity):
    dp = [0]*(capacity+1)
    for _ in range(num):
        weight, value = map(int, input().split())
        for w in range(capacity,weight - 1,-1):
            tmp = dp[w - weight] + value
            if dp[w] < tmp:
              dp[w] = tmp
    return dp[capacity]

num, capacity = map(int, input().split())
print(calc(num,capacity))
### BUGGY CODE ###

N, K = map(int, input().split())
hs = sorted([int(input()) for _ in range(N)])[::-1]

min_diff = 10 ** 10
for i in range(0, N-K+1):
    tmp = hs[i:i+K]
    min_diff = min(min_diff, tmp[0] - tmp[-1])

print(min_diff)


### FIXED CODE ###

N, K = map(int, input().split())
hs = sorted([int(input()) for _ in range(N)])

min_diff = 10 ** 10
for i in range(N-K+1):
    min_diff = min(min_diff, hs[i+K-1] - hs[i])

print(min_diff)
### BUGGY CODE ###

import sys

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def II(): return int(sys.stdin.readline())

N = II()
A_li = LI()

import fractions
from functools import reduce

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

print( max([gcd_list(A_li[:i]+A_li[i+1:]) for i in range(len(A_li))]) )


### FIXED CODE ###

import sys
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def II(): return int(sys.stdin.readline())

N = II()
A_li = LI()

import fractions
from functools import reduce
from functools import lru_cache

@lru_cache(maxsize=None)
def calc_gcd(a, b):
    return fractions.gcd(a, b)

def gcd_list(numbers):
    if len(numbers) == 0: return None
    elif len(numbers) == 1: return numbers[0]
    else: return reduce(calc_gcd, numbers)

left_gcd = [None,A_li[0]]
prev_gcd = A_li[0]
for i in range(1,N-1):
    prev_gcd = calc_gcd(prev_gcd, A_li[i])
    left_gcd.append(prev_gcd)

right_gcd = [None, A_li[N-1]]
prev_gcd = A_li[N-1]
for i in range(1,N-1):
    prev_gcd = calc_gcd(prev_gcd, A_li[N-1-i])
    right_gcd.append(prev_gcd)
right_gcd.reverse()

print(max([right_gcd[0]]+[calc_gcd(left_gcd[i], right_gcd[i]) for i in range(1,len(A_li)-1)]+[left_gcd[N-1]]))
### BUGGY CODE ###

X, K, D = map(int, input().split())

x = abs(X)
k = K
while x > 0 and k > 0:
    x -= D
    k -= 1

if k % 2 == 1:
    x += D

print(abs(x))


### FIXED CODE ###

X, K, D = map(int, input().split())

x = abs(X)
k = K

xd = min(x // D + 1, K)
x -= D * xd
k -= xd

if k % 2 == 1:
    x += D

print(abs(x))
### BUGGY CODE ###

x=int(input())
time=0
long=0
for i in range(1,2*x):
    if long<x:
        long+=i
        time+=1
print(time)

### FIXED CODE ###

import sys
x=int(input())
for i in range(1,x+1):
    long = (i*(i+1))/2
    if long>=x:
        print(i)
        sys.exit()
### BUGGY CODE ###

n = int(input())
ten = 0
two = 0
five = 0
while n > 1:
  if n % 2 == 0:
    two = 1
  if n % 5 == 0:
    five = 1
  if two == 1 and five == 1:
    ten = ten + 1
    
    two = 0
    five = 0
  n = n - 2
print(ten)

### FIXED CODE ###

n=int(input())
if n%2 == 0:
    num=10
    c=0;
    while num <= n:
        c += (n//num)
        num *= 5
    print(c)
else:
    print(0)
### BUGGY CODE ###

def have_loop(G, V):
    #Gに閉路があるかを判定 Gは隣接グラフによる表現. 0-based Vは頂点数
    parent = [{v} for v in range(V)] #各頂点の親集合
    reached = [False] * V
    for v in range(V):
        stack = []
        if not reached[v]:
            stack.append(v)
            while stack:
                u = stack.pop()
                reached[u] = True
                for w in G[u]:
                    if w in parent[u]:
                        return True
                    elif not reached[w]:
                        parent[w] |= parent[u]
                        stack.append(w)
    return False

N, M = map(int, input().split())
s = input()
G = [[] for _ in range(4 * N)]
for _ in range(M):
    a, b = map(lambda x: int(x) - 1, input().split())
    if s[a] == s[b]:
        G[a].append(b + N)
        G[b].append(a + N)
    else:
        G[a + N].append(b)
        G[b + N].append(a)
if have_loop(G, 4 * N):
    print('Yes')
else:
    print('No')


### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

N, M = map(int, input().split())
s = input()
G = [[] for _ in range(2 * N)]
for _ in range(M):
    a, b = map(lambda x: int(x) - 1, input().split())
    if s[a] == s[b]:
        G[a].append(b + N)
        G[b].append(a + N)
    else:
        G[a + N].append(b)
        G[b + N].append(a)

status = [0] * (2 * N) #0 = 未訪問　1 = 訪問中 2 = 訪問済
def dfs(v):
    if status[v] == 1:
        print('Yes')
        exit()
    elif status[v] == 0:
        status[v] = 1
        for u in G[v]:
            dfs(u)
        status[v] = 2

for v in range(2 * N):
    dfs(v)
print('No')
### BUGGY CODE ###

#TLE
n = int(input())
a = input().split()
dic = {}
ans = 0
a_copy = a.copy()
while a_copy != []:
    num = a_copy.count(a_copy[0]) - 1
    ans += num * (num+1)
    dic[a_copy[0]] = num
    a_copy = [i for i in a_copy if i != a_copy[0]]
ans /= 2
for i in range(n):
    print(int(ans - dic[a[i]]))

### FIXED CODE ###

#TLE
n = int(input())
a = input().split()
ans = 0
import collections
dic = collections.Counter(a)
for i in dic.values():
    ans += i * (i-1)
ans /= 2
for i in range(n):
    print(int(ans - dic[a[i]] + 1))
### BUGGY CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Jul  7 18:47:41 2020

@author: naoki
"""
import sys
import copy
def func():
    N, M = map(int, input().split())
    uvs = [list(map(lambda x:int(x)-1, input().split())) for _ in range(M)]
    S, T = map(lambda x:int(x)-1, input().split())
    
    roots = [[] for _ in range(N)]
    
    for uv in uvs:
        roots[uv[0]].append(uv[1])
    
    costs = [-10000]*(N)
    
    from collections import deque
    
    todo = deque([S])
    costs[S] = 0
    todo_set = set([S])
    
    while len(todo)>0:
        checking = todo.popleft()
        next_targets = deque([checking])
        for i in range(3):
            purposes = set()
            while len(next_targets) > 0:
                now = next_targets.pop()
                for root in roots[now]:
                    purposes.add(root)
            next_targets = purposes.copy()
        for next_target in next_targets:
            if costs[next_target] < 0 and next_target not in todo_set:
                costs[next_target] = costs[checking]+1
                todo.append(next_target)
                todo_set.add(next_target)
                if next_target == T:
                    print(costs[next_target])
                    sys.exit()
    print(-1)
if __name__ == "__main__":
    func()

### FIXED CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Jul  7 18:47:41 2020

@author: naoki
"""
import sys
import copy
def func():
    N, M = map(int, input().split())
    uvs = [list(map(lambda x:int(x)-1, input().split())) for _ in range(M)]
    S, T = map(lambda x:int(x)-1, input().split())
    
    roots = [[] for _ in range(N)]
    
    for uv in uvs:
        roots[uv[0]].append(uv[1])
    
    costs = [-10000]*(N)
    
    from collections import deque
    
    todo = deque([S])
    costs[S] = 0
    todo_set = set([S])
    
    layers = [set() for _ in range(3)]
    
    while len(todo)>0:
        checking = todo.popleft()
        next_targets = deque([checking])
        for i in range(3):
            purposes = set()
            while len(next_targets) > 0:
                now = next_targets.pop()
                for root in roots[now]:
                    if root not in layers[i]:
                        layers[i].add(root)
                        purposes.add(root)
            next_targets = purposes.copy()
        for next_target in next_targets:
            if costs[next_target] < 0 and next_target not in todo_set:
                costs[next_target] = costs[checking]+1
                todo.append(next_target)
                todo_set.add(next_target)
                if next_target == T:
                    print(costs[next_target])
                    sys.exit()
    print(-1)
if __name__ == "__main__":
    func()
### BUGGY CODE ###

def default():
    n=int(input())
    answer=1
    temp=input()
    temp=temp.split()
    for i in range(0,n):
        temp[i]=int(temp[i])
        answer*=temp[i]
    if(answer>1000000000000000000):
        print(-1)
    else:
        print(answer)

if(__name__=="__main__"):
    default()


### FIXED CODE ###

def default():
    maxi=1000000000000000000
    n=int(input())
    answer=1
    temp=input()
    temp=temp.split()
    flag=0
    for i in range(0,n):
        temp[i]=int(temp[i])
    temp.sort()
    for i in range(0,n):
        answer*=temp[i]
        if(answer>maxi):
            flag=1
            break
        if(temp[i]==0):
            flag==2
            break
    if(flag==1):
        print(-1)
    else:
        if(flag==2):
            print(0)
        else:
            print(answer)

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

N = int(input())  # 個数
A = [int(i) for i in input().split()]  # 整数

sum = 0
for i in range(N-1):
    for j in range(i+1, N):
        sum += A[i]*A[j]

print(sum % 1000000007)


### FIXED CODE ###

N = int(input())  # 個数
A = [int(i) for i in input().split()]  # 整数

sum_Aij = 0
sum_j = [0] * (N - 1)
for i in range(N - 1, 0, -1):
    sum_j[i - 1] = (A[i] + (0 if i == N - 1 else sum_j[i])) % 1000000007
    sum_Aij += sum_j[i - 1] * A[i - 1] % 1000000007

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

s = input()
dp = [[0 for i in range(13)]]
if s[-1] != "?":
    dp[0][int(s[-1]) % 13] += 1
else:
    for k in range(10):
        dp[0][k % 13] += 1
        
d = [1]   
for i in range(1,len(s)):
    dp.append([0]*13)
    d.append(d[i-1]*10 % 13)
    for r in range(13):
        if s[-(i+1)] == "?":
            for k in range(10): 
                dp[i][(k * d[i] + r) % 13] += dp[i-1][r] % (10**9 + 7)
                
        else:
            dp[i][(int(s[-(i+1)]) * d[i] + r) % 13] += dp[i-1][r] % (10**9 + 7)

print(dp[len(s)-1][5]%(10**9+7))


### FIXED CODE ###

s = input()
dp = [[0 for i in range(13)]]
if s[-1] != "?":
    dp[0][int(s[-1]) % 13] += 1
else:
    for k in range(10):
        dp[0][k % 13] += 1
        
d = [1]   
for i in range(1,len(s)):
    dp.append([0]*13)
    d.append(d[i-1]*10 % 13)
    for r in range(13):
        if s[-(i+1)] == "?":
            for k in range(10): 
                dp[i][(k * d[i] + r) % 13] += dp[i-1][r] % (10**9 + 7)
                
        else:
            dp[i][(int(s[-(i+1)]) * d[i] + r) % 13] += dp[i-1][r] % (10**9 + 7)

print(dp[len(s)-1][5]%(10**9+7))
### BUGGY CODE ###

s=[int(x) for x in list(input())]
cnt=0
l=0
while 1:
  #print(s,l)
  if len(s)<2 or l ==len(s)-1:
    break
  #print(l)
  if s[l]^s[l+1]:
    s.pop(l)
    s.pop(l)
    cnt += 2
    l=0
  else:
    l += 1
print(cnt)

### FIXED CODE ###

s=[int(x) for x in list(input())]
x=s.count(0)
print(min(x,len(s)-x)*2)
### BUGGY CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
f = list(map(int, input().split()))
a.sort()
f.sort(reverse=True)

def solve(x):
    lk = k
    for i, j in zip(a, f):
        if i*j<=x:
            continue
        lk -= (j*(i+1)-x-1)//j
        if lk<0:
            return False
    return True

ok = 10**12
ng = -1
while abs(ok-ng)>1:
    mid = (ok+ng)//2
    if solve(mid):
        ok = mid
    else:
        ng = mid

print(ok)

### FIXED CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
f = list(map(int, input().split()))
a.sort()
f.sort(reverse=True)

def solve(x):
    lk = k
    for i, j in zip(a, f):
        if i*j<=x:
            continue
        lk -= (j*(i+1)-x-1)//j
        if lk<0:
            return False
    return True

ok = 10**12
ng = -1
while abs(ok-ng)>1:
    mid = (ok+ng)//2
    if solve(mid):
        ok = mid
    else:
        ng = mid

print(ok)
### BUGGY CODE ###

N = int(input())
S = input()
anss = []
for i in range(1000):
    str_i = str(i).zfill(3)
    idx = 0
    ans = ""
    for j in range(N):
        if S[j] == str_i[idx]:
            if idx == 2:
                ans += str_i[idx]
                anss.append(ans)
                break
            else:
                ans += str_i[idx]
                idx += 1
print(len(set(anss)))

### FIXED CODE ###

N = int(input())
S = input()
anss = []
for i in range(1000):
    str_i = str(i).zfill(3)
    idx1 = S.find(str_i[0], 0)
    idx2 = S.find(str_i[1], idx1 + 1)
    idx3 = S.find(str_i[2], idx2 + 1)
    if idx1 != -1 and idx2 != -1 and idx3 != -1:
        anss.append(str_i)

print(len(set(anss)))
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
A.sort()
b = [False] * len(A)

for i in range(N):
  for j in range(N):
    if b[j] or i == j or A[i] > 500000:
      continue
    if A[j] % A[i] == 0:
      b[j] = True

# print(b)

print(len(tuple(filter(lambda x: x == False, b))))


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
A.sort()
M = A[-1]
b = [True] * (M + 1)

count = 0
for i, a in enumerate(A):
  if not b[a]:
    continue
  for j in range(a, M+1, a):
    b[j] = False
  if i < N-1 and A[i+1] == a:
    continue
  count += 1

print(count)
### BUGGY CODE ###

N,K=map(int,input().split())
h=[int(input()) for i in range(N)]
h.sort()
mindif=h[K-1]-h[0]
for i in range(N-K+1):
    tmp=h[i:i+K]
    dif=tmp[-1]-tmp[0]
    if mindif>dif:
        mindif=dif
print(mindif)


### FIXED CODE ###

N,K=map(int,input().split())
h=[int(input()) for i in range(N)]
h.sort()
mindif=h[K-1]-h[0]
for i in range(N-K+1):
    dif=h[i+K-1]-h[i]
    if mindif>dif:
        mindif=dif
print(mindif)