Harryxun/stf_run huggingface dataset:
N, M =map(int,input().split())
cards = list(map(int,input().split()))
card_pool = [list(map(int,input().split())) for _ in range(M)]
cards.sort()
#print(cards)
card_pool.sort(key=lambda x:x[1],reverse=True)
#print(card_pool)


ruisekiwa = 0
idx = 0
for i in range(M):
    for j in range(card_pool[i][0]):
        if card_pool[i][1] < cards[idx]:
            break
        ruisekiwa += card_pool[i][1]
        idx += 1
print(sum(cards[idx:])+ruisekiwa)



### FIXED CODE ###

N,M = map(int,input().split())
*A, = map(int,input().split())
BC=[list(map(int,input().split())) for _ in [0]*M]
A.sort()
BC.sort(key=lambda x:-x[1])
i = 0
for B,C in BC:
    for j in range(i,min(N,i+B)):
        if A[j]<C:A[j]=C
    i = i+B
print(sum(A))
weather = input()
if: weather == "Sunny"
    print("Cloudy")
elif: weather == "Cloudy"
    print("Rainy")
else:
    print("Sunny")

### FIXED CODE ###

a = input()
if a == "Sunny":
    print("Cloudy")
elif a == "Cloudy":
    print("Rainy")
else :
    print("Sunny")
def solve(a,b,c,x):
    count = 0
    for i in range(a+1):
        for j in range(b+1):
            for k in range(c+1):
                if 500*i+100*j+50*k == x:
                    count += 1
    return count

A,B,C,X = map(int, input().split(" "))
print(solve(A,B,C,X))

### FIXED CODE ###

def solve(a,b,c,x):
    count = 0
    for i in range(a+1):
        for j in range(b+1):
            for k in range(c+1):
                if 500*i+100*j+50*k == x:
                    count += 1
    return count

A = int(input())
B = int(input())
C = int(input())
X = int(input())

print(solve(A,B,C,X))
N = input()
 
for n in range(N):
    data = map(float,input().split( ))
    slopes = []
    for i in range(2):
        _x1 = data.pop(0)
        _y1 = data.pop(0)
        _x2 = data.pop(0)
        _y2 = data.pop(0)
         
        if _x1 != _x2:
            slopes.append((_y1 - _y2)/(_x1 - _x2))
     
    if len(slopes) == 0:
        print("YES")
    elif len(slopes) == 1:
        print("NO")
    elif abs(slopes[0] - slopes[1]) < 1e-10:
        print("YES")
    else:
        print("NO")

### FIXED CODE ###

N = input()
 
for n in range(N):
    data = map(float,raw_input().split( ))
    slopes = []
    for i in range(2):
        _x1 = data.pop(0)
        _y1 = data.pop(0)
        _x2 = data.pop(0)
        _y2 = data.pop(0)
         
        if _x1 != _x2:
            slopes.append((_y1 - _y2)/(_x1 - _x2))
     
    if len(slopes) == 0:
        print "YES"
    elif len(slopes) == 1:
        print "NO"
    elif abs(slopes[0] - slopes[1]) < 1e-10:
        print "YES"
    else:
        print "NO"
s = str(input())
s_ = list(s)
for i in range(len(s)):
  if i==0 and len(s)==1 and s_[i]=='?':
    s_[i]='D'
  elif i==0 and s_[i]=='?' and s_[i+1]=='D':
      s_[i]='P'
  elif i==0 and s_[i]=='?' and s_[i+1]=='P':
      s_[i]='D'
  elif s_[i]=='?' and s[i-1]=='P':
    s_[i]='D'
  elif s_[i]=='?' and s[i-1]=='D':
    if i=len(s)-1:
      s_[i]='D'
    if s_[i+1]=='D':
      s_[i]='P'
    elif s_[i+1]=='?':
      s_[i]='P'
      s_[i+1]='D'
    else:
      s_[i]='D'
    
S = "".join(s_)
print(S)

### FIXED CODE ###

s = str(input())
s_ = list(s)
for i in range(len(s)):
  if s_[i]=='?':
    s_[i]='D'
S = "".join(s_)
print(S)
def add_to_subtree(tree, result_arr, idx, value):
  result_arr[idx] += value
  if len(tree[idx]) == 0:
    return
  for child in tree[idx]:
    add_to_subtree(tree, result_arr, child, value)

N, Q = map(int, input().split())
T = [[] for i in range(N + 1)]
R = [0] * (N + 1)
for _ in range(N-1):
  a, b = map(int, input().split())
  T[a].append(b)
for _ in range(Q):
  P, X = map(int, input().split())
  add_to_subtree(T, R, P, X)

print(" ".join(map(str, R[1:])))


### FIXED CODE ###

import collections
N, Q = map(int, input().split())
counts = [0] * (N + 1)
T = [[] for _ in range(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())
  counts[p] += x
visited = [0] * (N + 1)
queue = collections.deque()
queue.append(1)
while queue:
  v = queue.pop()
  visited[v] = 1
  x = counts[v]
  for child in T[v]:
    if visited[child] == 1:
      continue
    counts[child] += x
    queue.append(child)
print(*counts[1:])
n,m = map(int,input().split())
p,y = [],[]
for i in range(m):
    v1,v2 = map(int,input().split())
    p.append(v1)
    y.append(v2)
    
py = zip(p,y,range(m))
py = sorted(py)
p,y,index = zip(*py)
 
ans = []
start = p[0]
count = 1
for i in range(m):
    if start == p[i]:
        ans.append(str(p[i]).zfill(6) + str(count).zfill(6))
        count += 1
    else:
        count = 1
        start = p[i]
        ans.append(str(p[i]).zfill(6) + str(count).zfill(6))
        count += 1
 
ans = zip(index,ans)
ans = sorted(ans1)
index,ans = zip(*ans)
for i in ans:
    print(i)

### FIXED CODE ###

n,m = map(int,input().split())
p,y = [],[]
for i in range(m):
    v1,v2 = map(int,input().split())
    p.append(v1)
    y.append(v2)
    
py = zip(p,y,range(m))
py = sorted(py)
p,y,index = zip(*py)

ans = []
start = p[0]
count = 1
for i in range(m):
    if start == p[i]:
        ans.append(str(p[i]).zfill(6) + str(count).zfill(6))
        count += 1
    else:
        count = 1
        start = p[i]
        ans.append(str(p[i]).zfill(6) + str(count).zfill(6))
        count += 1

ans1 = zip(index,ans)
ans1 = sorted(ans1)
index,ans = zip(*ans1)
for i in ans:
    print(i)
a,b=map(int,input().split())

print(ceil(a+b)/2)

### FIXED CODE ###

import math
a,b=map(int,input().split())
x=math.ceil((a+b)/2)
print(x)
def main():
    N = input()
    CS = [c for c in input().strip()]

    wtotal = 0
    rtotal = 0
    for c in CS:
        if c == "W":
            wtotal += 1
        elif c == "R":
            rtotal += 1
        else:
            raise Exception()

    upper_bound = min(wtotal, rtotal)

    left = -1
    right = len(CS)

    op = 0
    w = 0
    r = 0
    while True:
        if w > r:
            right -= 1
            if CS[right] == "R":
                r += 1
        else:
            left += 1
            if CS[left] == "W":
                w += 1

        if w > 0 and r > 0:
            op += 1
            w -= 1
            r -= 1

        if right == left:
            break

    change = op + w + r
    print(min(upper_bound, change))


main()


### FIXED CODE ###

def main():
    N = input()
    CS = [c for c in input().strip()]

    wtotal = 0
    rtotal = 0
    for c in CS:
        if c == "W":
            wtotal += 1
        elif c == "R":
            rtotal += 1
        else:
            raise Exception()

    left = -1
    right = len(CS)

    op = 0
    w = 0
    r = 0
    while True:
        # print(f"L:{left}  R:{right}  w:{w}  r:{r}  op:{op}")
        if w > r:
            right -= 1
            if CS[right] == "R":
                r += 1
        else:
            left += 1
            if CS[left] == "W":
                w += 1

        if w > 0 and r > 0:
            op += 1
            w -= 1
            r -= 1

        if right == left or right == 0 or left == len(CS) - 1:
            break

    change = op
    print(min(wtotal, rtotal, change))


main()
S=str(input())
T=str(input())
t=1000

for i in range(1000):
  try:
    k=S[i]
  except IndexError:
    Slen=i
    break
for j in range(1000):
  try:
    k=T[j]
  except IndexError:
    Tlen=j
    break
lists=[]
for i in range(Slen-Tlen):
  s=0
  for j in range(Tlen):
    if S[i+j]==T[j]:
      s+=1
    else:
      continue
  t=min(t,Tlen-s)
print (t)

### FIXED CODE ###

S=str(input())
T=str(input())
t=1000
Slen=1000
Tlen=1000
for i in range(1000):
  try:
    k=S[i]
  except IndexError:
    Slen=i
    break
for j in range(1000):
  try:
    k=T[j]
  except IndexError:
    Tlen=j
    break

for i in range(Slen-Tlen+1):
  s=0
  for j in range(Tlen):
    if S[i+j]==T[j]:
      s+=1
    else:
      continue
  t=min(t,Tlen-s)
print (t)
for num in range(0, 5, 1):
    x = int(input())
    if x == 0:
        print(num + 1)
        exit()

### FIXED CODE ###

line = list(map(int, input().split()))
cnt = 1
for num in line:
    if num == 0:
        print(cnt)
        exit()

    cnt+=1
N,K = map(int,input().split())

mod = 10**9+7

m = N
fac = [1]*m
ninv = [1]*m
finv = [1]*m
for i in range(2,m):
    fac[i] = fac[i-1]*i%mod
    ninv[i] = (-(mod//i)*ninv[mod%i])%mod
    finv[i] = finv[i-1]*ninv[i]%mod

def comb(n,k):
    if n<0 or k<0 or k>n:return 0
    return (fac[n]*finv[k]%mod)*finv[n-k]%mod

for i in range(1,K+1):
    print(comb(N-K+1,i)*comb(K-1,i-1)%mod)

### FIXED CODE ###

N,K = map(int,input().split())

mod = 10**9+7

m = N+1
fac = [1]*m
ninv = [1]*m
finv = [1]*m
for i in range(2,m):
    fac[i] = fac[i-1]*i%mod
    ninv[i] = (-(mod//i)*ninv[mod%i])%mod
    finv[i] = finv[i-1]*ninv[i]%mod

def comb(n,k):
    if n<0 or k<0 or k>n:return 0
    return (fac[n]*finv[k]%mod)*finv[n-k]%mod

for i in range(1,K+1):
    print(comb(N-K+1,i)*comb(K-1,i-1)%mod)
N, K = input().split()
l = list(int(i) for i int input().split())
count = 0
 
for i in l:
  if(i > K):
    count = count + 1

print(count)

### FIXED CODE ###

Ns = input()
N = int(Ns)
if(N % 2 == 1):
  if(N == 1):
    print('{:.7f}'.format(N))
  else:
    print('{:.7f}'.format(((N+1)/2)/N))
else:
  print('{:.7f}'.format(1/2))
X,A = int(a) for a in input().split()
if X<A:
    print("0")
else:
    print("10")

### FIXED CODE ###

X,A = (int(a) for a in input().split())
if A>X:
  print("0")
else:
  print("10")
n = input()
l = sorted[int(x) for x in raw_input().split()]
print l[n/2] - l[n/2-1]

### FIXED CODE ###

n = input()
l = sorted([int(x) for x in raw_input().split()])
print l[n/2] - l[n/2-1]
H, W, K = map(int, input().split())
S = [list(map(int, input())) for i in range(H)]

ret = W - 1 + H - 1

for i in range(1 << (H - 1)):
    sep = bin(i)[2:].rjust(H - 1, '0')[::-1]

    tile_idx = [0] * H
    cut = 0

    for j in range(H):
        tile_idx[j] = cut

        if j == H - 1:
            break

        if sep[j] == '1':
            cut += 1

    cnt_lst = [0] * (cut + 1)

    num_cnt = 0

    for w in range(W):
        col_new = [0] * (cut + 1)

        flag = False
        for h in range(H):
            if S[h][w] == 1:
                idx = tile_idx[h]
                col_new[idx] += 1

        for a in col_new:
            if a > K:
                flag = True
                break

        for k in range(cut + 1):
            if cnt_lst[k] + col_new[k] > K:
                num_cnt += 1
                cnt_lst = col_new.copy()
                flag = True
                break

        if not flag:
            for k in range(cut + 1):
                cnt_lst[k] += col_new[k]

    ret = min(ret, num_cnt + cut)


print(ret)


### FIXED CODE ###

H, W, K = map(int, input().split())
S = [list(map(int, input())) for i in range(H)]

ret = W - 1 + H - 1

for i in range(1 << (H - 1)):
    sep = bin(i)[2:].rjust(H - 1, '0')[::-1]

    tile_idx = [0] * H
    cut = 0

    for j in range(H):
        tile_idx[j] = cut

        if j == H - 1:
            break

        if sep[j] == '1':
            cut += 1

    cnt_lst = [0] * (cut + 1)
    num_cnt = 0

    for w in range(W):
        col_new = [0] * (cut + 1)

        flag = False
        flag1 = False
        for h in range(H):
            if S[h][w] == 1:
                idx = tile_idx[h]
                col_new[idx] += 1

        for a in col_new:
            if a > K:
                flag1 = True
                break

        if flag1:
            break

        for k in range(cut + 1):
            if cnt_lst[k] + col_new[k] > K:
                num_cnt += 1
                for l in range(cut + 1):
                    cnt_lst[l] = col_new[l]

                flag = True
                break

        if not flag:
            for k in range(cut + 1):
                cnt_lst[k] += col_new[k]

    if not flag1:
        ret = min(ret, num_cnt + cut)


print(ret)
N=input()
def waru(num):
    return int(num)//400
    
a = list(map(waru, input().split()))
num = 0
for i in a:
    num+=1 if i >= 8 else 0
min = len(set(a))-num+1

print(min, num+min)


### FIXED CODE ###

tmp = input().split()
tmp1 = int(''.join(tmp))
if tmp1%4 == 0:
    print('YES')
else:
    print('NO')
a, b  = map(int, input().split())

for i in range(10000):
  if a * 0.08 == b * 0.1:
    print(a)
    exit(0)
  else:
    print('-1')
    


### FIXED CODE ###

s = input()
if s == 'AAA' or s == 'BBB':
  print('No')
else:
  print('Yes')
n = input('input N: ')

c, s, f = [], [], []
for i in range(int(n) - 1):
    tmp = input('input C, S, F: ').split()
    c.append(tmp[0])
    s.append(tmp[1])
    f.append(tmp[2])

# n = 3
# c = [6, 1]
# s = [5, 10]
# f = [1, 1]
# n = 4
# c = [12, 52, 99]
# s = [24, 16, 2]
# f = [6, 4, 2]
# n = 4
# c = [12, 44, 66]
# s = [13, 17, 4096]
# f = [1, 17, 64]

a = [None] * n
for i in reversed(range(int(n))):

    if i == n - 1:
        a[i] = 0
        continue

    ta = s[i] + c[i]
    if i == n - 2:
        a[i] = ta
        continue

    for j in range(i, n - 2):
        nn = j + 1
        if ta <= s[nn]:
            ta = a[nn]
        else:
            yo = ta % f[nn]
            add = 0 if yo == 0 else f[nn] - yo
            ta += add + c[nn]
    a[i] = ta


[print(aa) for aa in a]


### FIXED CODE ###

def c_SpecialTrains(N, STATION):
    ans = []
    for i in range(N):
        t = 0  # 駅iからNまでにかかる時間
        for j in range(i, N - 1):
            c, s, f = STATION[j]
            if t < s:
                t = s  # まだ運行していないので、運行するまで待つ必要がある
            elif t % f == 0:
                # tがfで割り切れるなら、すぐに鉄道に乗ればよい
                # sはfで割り切れることが保証されているので、この条件式でよい
                pass
            else:
                t += f - (t % f)  # この分だけ駅で待つ必要がある
            t += c  # 次の駅までかかる時間
        ans.append(t)
    return '\n'.join(map(str, ans))
 
N = int(input())
STATION = [[int(i) for i in input().split()] for j in range(N-1)]
print(c_SpecialTrains(N, STATION))
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0
inf = float("inf")

S = s()
n = len(S)
a = S[:N//2]
b = S[N//2+1:]
print("Yes" if a == a[::-1] == b == b[::-1] else "No")


### FIXED CODE ###

import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0
inf = float("inf")

S = s()
n = len(S)
a = S[:n//2]
b = S[n//2+1:]
print("Yes" if a == a[::-1] == b == b[::-1] else "No")
#coding: utf-8

N, M = map(int, input().split())

List = []
all_and = []
for i in range(N):
    l = list(map(int, input().split()))
    #print(l)
    del l[0]
    #print(l)
    List.append(l)
    #print(List[i])
    #print(List)
    #print( )

    all_and = set(all_and) & set(List[i])
    all_and = List(all_and)

all_and_list = list(all_and)
#print(all_and)
#print(all_and_list)
print(len(all_and_list))


### FIXED CODE ###

#coding: utf-8

N, M = map(int, input().split())

List = []
all_and = []
for i in range(N):
    l = list(map(int, input().split()))
    del l[0]
    List.append(l)

    if i ==0:
        all_and = List[0]
    else:
        all_and = set(all_and) & set(List[i])
        all_and = list(all_and)

#print(all_and)
print(len(all_and))
N = int(input())
fn = 0
for i in range(1, 9):
    fn += N // (10*i)
if N % fn == 0:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

N = input().rstrip('\r')
fx = 0
for n in N:
    num = int(n)
    fx += num
if int(N) % fx == 0:
    print('Yes')
else:
    print('No')
import math

N,X = map(int,input().split())
x = list(map(int,input().split()))
if N == 1:
    print(abs(x[0] - X))
else:
    xlen = [abs(x[0]-X)]
    for i in range(N-1):
        xlen.append(x[i+1]- x[i])
    ans = xlen[0]
    for i in range(1,N):
        ans = math.gcd(ans,xlen[i])
    print(ans)

### FIXED CODE ###

def gcd(a,b) :
    if b>0 :
        return gcd(b,a % b)
    elif b == 0:
        return a


N,X = map(int,input().split())
x = list(map(int,input().split()))
if N == 1:
    print(abs(x[0] - X))
else:
    xlen = []
    for i in range(N):
        xlen.append(abs(x[i] - X))
        #print(xlen[i])
    ans = xlen[0]
    for i in range(1,N):
        ans = gcd(ans,xlen[i])
        #print(ans)
    print(ans)
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
ans = 0
m = abs(A - T + h[0] * 0.006)
for i in range(N):
  d = T - h[i] * 0.006
  a = abs(A - d)
  if m >= a:
    m = a
    ans = i
print(ans)

### FIXED CODE ###

N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
ans = 0
m = abs(A - T + H[0] * 0.006)
for i in range(N):
  d = T - H[i] * 0.006
  a = abs(A - d)
  if m >= a:
    m = a
    ans = i + 1
print(ans)
n,l=map(int,input().split(" "))
words=[input() for i in range(0,l)]
words.sort()
words="".join(words)
print(words)

### FIXED CODE ###

n,l=map(int,input().split(" "))
words=[input() for i in range(0,n)]
words.sort()
words="".join(words)
print(words)
import sys
input = sys.stdin.readline
from collections import defaultdict

N = int(input())
d = defaultdict(int)
for _ in range(N):
    s = list(input().rstrip("\r\n"))
    s.sort()
    d["".join(s)] += 1
ans = 0

def count(v):
    if v == 0:
        return 0
    return v + count(v-1)
for k in d:
    ans += count(d[k]-1)
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline
from collections import defaultdict
sys.setrecursionlimit(10 ** 9)

N = int(input())
d = defaultdict(int)
for _ in range(N):
    s = list(input().rstrip("\r\n"))
    s.sort()
    d["".join(s)] += 1
ans = 0
def count(v):
    if v == 0:
        return 0
    return v + count(v-1)
for k in d:
    ans += count(d[k]-1)
print(ans)
a = input().split()
x = int(a[0])
y = int(a[1])
def h(x,y):
    d = {1:300000,2:200000,1:100000}
    if x==1 and y ==1:
        return 1000000
    print(d.get(x)+y.get(y))
h(x,y)

### FIXED CODE ###

a = input().split()
#print(a)
x = a[0]
y = a[1]
def h(x,y):
    d = dict()
    d = {'1':300000,'2':200000,'3':100000}
    if x=='1' and y =='1':
        print(1000000)
        return
    res = 0
    res = d.get(x,0) + d.get(y,0)
    print(int(res))
h(x,y)
ans = 0
def count_ans(level, index, len_dic, p_dic):
    global ans
    if level == 0:
        ans += 1
    else:
        if index == 0:
            pass
        elif index == len_dic[level] // 2:
            ans += 1
            ans += p_dic[level - 1]
        elif index == len_dic[level] - 1:
            ans += p_dic[level]
        elif index > len_dic[level] // 2:
            ans += p_dic[level - 1] + 1
            index_next = index - len_dic[level - 1] - 2
            count_ans(level - 1, index_next, len_dic, p_dic)
        else:
            index_next = index - 1
            count_ans(level - 1, index_next, len_dic, p_dic)


def get_len_dic(level):
    len_dic = [1]
    for i in range(level):
        len_dic.append(len_dic[-1] * 2 + 3)
    return len_dic

def get_p_dic(level):
    p_dic = [1]
    for i in range(level - 1):
        p_dic.append(p_dic[-1] * 2 + 1)
    return p_dic

def main():
    global ans
    level, eat_num = map(int, input().split())
    len_dic = get_len_dic(level)
    p_dic = get_p_dic(level)
    count_ans(level, eat_num - 1, len_dic, p_dic)
    print(ans)


if __name__ == '__main__':
    main()

### FIXED CODE ###


ans = 0
def count_ans(level, index, len_dic, p_dic):
    global ans
    if level == 0:
        ans += 1
    else:
        if index == 0:
            pass
        elif index == len_dic[level] // 2:
            ans += 1
            ans += p_dic[level - 1]
        elif index == len_dic[level] - 1:
            ans += p_dic[level]
        elif index > len_dic[level] // 2:
            ans += p_dic[level - 1] + 1
            index_next = index - len_dic[level - 1] - 2
            count_ans(level - 1, index_next, len_dic, p_dic)
        else:
            index_next = index - 1
            count_ans(level - 1, index_next, len_dic, p_dic)


def get_len_dic(level):
    len_dic = [1]
    for i in range(level):
        len_dic.append(len_dic[-1] * 2 + 3)
    return len_dic

def get_p_dic(level):
    p_dic = [1]
    for i in range(level):
        p_dic.append(p_dic[-1] * 2 + 1)
    return p_dic

def main():
    global ans
    level, eat_num = map(int, input().split())
    len_dic = get_len_dic(level)
    p_dic = get_p_dic(level)
    count_ans(level, eat_num - 1, len_dic, p_dic)
    print(ans)


if __name__ == '__main__':
    main()
import math
n = int(input())
a = list(map(int,input().split()))
max_a = max(a)
min_a = min(a)
ab = 0

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

if max_a % 2 == 0:
    for i in range(n):
        if a[i] % 2 == 1:
            ab = (lcm(a[i+1], a[i]))
            break
else:
    ab = (lcm(max_a, min_[i]))
    
if ab == 0:
    print(n)
else:   
    ans = 0
    for i in a:
        ans += ab//i

    print(ans)

### FIXED CODE ###

import fractions
N = int(input())
a = list(map(int, input().split()))
ans = a[0]
for i in range(1, N):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
    
count = 0
for i in a:
    count += ans//i
print(count%(10**9+7))
s=input()
if s==ABC:
  print('ARC')

elif s==ARC:
  print('ABC')
  

### FIXED CODE ###

s=input()
if s=='ABC':
  print('ARC')

elif s=='ARC':
  print('ABC')
N,K = map(int,input().split())
if K == 1:
    print(1)
else:
    for i in range(1,K+1):
        if i == 1 or i == K:
            print(comb(N-K+1,i,10**9+7))
        else:
            k = factorial(N-K+1) #% (10**9+7)
            l = factorial(N-K+1-i) #% (10**9+7)
            m = factorial(i-1) #% (10**9+7)
            #print(k,l,m)
            #print( (k//(l*m)))
            print( (k//(l*m)) % (10**9+7))
           #print(comb(N-K+1,i,10**9+7))

### FIXED CODE ###

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
mod = 10**9+7
MAX = 4000
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
for i in range( 2, MAX + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
n,k= map(int,input().split())
for i in range(1,k+1):
    pre = cmb(k-1,i-1,mod)
    pos = cmb(n-k+1,i,mod)
    print((pre*pos)%mod)
n = int(raw_input())
A = map(int, raw_input().split(' '))
q = int(raw_input())
M = map(int, raw_input().split(' '))


S = [0]*len(A)
flags = [False]*len(M)
def brute_force(n):
    if n == len(S):
        ans = 0
        for i in range(len(S)):
            if S[i] == 1: ans += A[i]
        for i in range(len(M)):
            if ans == M[i]: flags[i] = True
    else:
        S[n] = 0
        brute_force(n+1)
        S[n] = 1
        brute_force(n+1)


brute_force(0)

for flag in flags:
    if flag: print "yes"
    else: print "no"

### FIXED CODE ###

n = int(raw_input())
A = map(int, raw_input().strip().split(' '))
q = int(raw_input())
M = map(int, raw_input().strip().split(' '))

memo = []
for i in range(len(A)+1):
    memo.append([None]*2000)

def solve(i,m):
    if memo[i][m] != None: return memo[i][m]
    if m == 0:
        memo[i][m] = True
        return True
    elif i >= n:
        memo[i][m] = False
        return False
    else:
        ret = solve(i+1,m) | solve(i+1,m-A[i])
        memo[i][m] = ret
        return ret

for m in M:
    if solve(0,m): print "yes"
    else: print "no"