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

import math
import fractions
n = int(input())
a_ls = list(map(int,input().split()))
lcm = 1
ans = 0
mod = 10**9+7
for i in a_ls:
    lcm = lcm * i//fractions.gcd(lcm,i)
for i in a_ls:
    ans += (lcm//i)%mod
print(ans%mod)


### FIXED CODE ###

import math
import fractions
n = int(input())
a_ls = list(map(int,input().split()))
lcm = 1
ans = 0
mod = 10**9+7
for i in a_ls:
    lcm = lcm * i//fractions.gcd(lcm,i)
for i in a_ls:
    ans += lcm//i
print(ans%mod)
### BUGGY CODE ###

n = int(input())
from collections import defaultdict
d = defaultdict(int)

for i in range(1,n):
	for j in range(1,n):
		for k in range(1,n):
			if i+j+k <= 150:
				p = (i+j+k)**2-(i*j)-(j*k)-(i*k)
				d[p]+=1

for i in range(1,n+1):
	print(d[i])


### FIXED CODE ###

n = int(input())
from collections import defaultdict
d = defaultdict(int)

for i in range(1,min(n,100)):
	for j in range(1,min(n,100)):
		for k in range(1,min(n,100)):
			if i+j+k <= 150:
				p = (i+j+k)**2-(i*j)-(j*k)-(i*k)
				d[p]+=1

for i in range(1,n+1):
	print(d[i])
### BUGGY CODE ###

N=int(input())
AB=list()
for i in range(N):
    AB.append(list(map(int,input().split())))
CD=list()
for i in range(N):
    CD.append(list(map(int,input().split())))
import itertools
ans=0
for v in itertools.permutations(CD):
    s=0
    for x,y in zip(AB,v):
        if x[0]<y[0] and x[1]<y[1]:
            s+=1
    if s>ans:
        ans=s
print(ans)


### FIXED CODE ###

n=int(input())
ab=list()
cd=list()
for i in range(n):
    ab.append(list(map(int,input().split())))
for j in range(n):
    cd.append(list(map(int,input().split())))
cd.sort(key=lambda x:x[0])
AB=[[-1,-1]]*n
for i in range(n):
    S=[x for x in ab if x[0]<cd[i][0] and x[1]<cd[i][1]]
    S.sort(key=lambda k:k[1])
    if len(S)>0:
        AB[i]=S[-1]
        ab.remove(S[-1])
print(len(AB)-AB.count([-1,-1]))
### BUGGY CODE ###

def main():
    N=int(input())
    A=[int(x) for x in input().split()]
    ans=1
    for a in A:
        ans*=a
    if ans > 10**18:
        print(-1)
    else:
        print(ans)
    return

if __name__=='__main__':
    main()


### FIXED CODE ###

def main():
    N=int(input())
    A=[int(x) for x in input().split()]
    A.sort()
    ans=1
    for a in A:
        ans*=a
        if ans > 10**18:
            break
        elif ans == 0:
            break
    if ans > 10**18:
        print(-1)
    else:
        print(ans)
    return

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

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

count = 0
ans=[]
for i in range(M):
    l, r = map(int, input().split())
    if count == 0:
        for j in range(l, r+1):
            ans.append(j)
    else:
        tmp = []
        for j in range(l, r+1):
            tmp.append(j)
        ans = list(set(tmp) & set(ans))
    count += 1

print(len(ans))


### FIXED CODE ###


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

L = []
R = []

for i in range(M):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)

maxl = max(L)
minr = min(R)

ans = minr - maxl + 1
if ans > 0:
    print(ans)
else:
    print(0)
### BUGGY CODE ###

n = int(input())
P = list(map(float, input().split()))

#dp[i][j] i枚投げた時にj枚表の確率
dp = [[0] * (n + 1) for _ in range(n + 1)]
dp[0][0] = 1.0

for i in range(n):
  for j in range(i + 1):
    dp[i+1][j+1] += dp[i][j] * P[i]
    dp[i+1][j] += dp[i][j] * (1 - P[i])
    
ans = sum([dp[n][j] for j in range(n + 1) if j * 2 > n])
      
print(ans)


### FIXED CODE ###

n = int(input())
P = list(map(float, input().split()))

#dp[i][j] i枚投げた時にj枚表の確率
dp = [[0] * (n + 1) for _ in range(n + 1)]
dp[0][0] = 1.0

for i in range(n):
  for j in range(i + 1):
    dp[i+1][j+1] += dp[i][j] * P[i]
    dp[i+1][j] += dp[i][j] * (1 - P[i])
    
ans = sum([dp[n][j] for j in range(n + 1) if j * 2 > n])
      
print(ans)
### BUGGY CODE ###

N=int(input())
S=input()

li=[]
uni_list=[]

for i in range(N-2):
    for j in range(N-1):
        if j>i:
            for k in range(N):
                if k>j:
                    li.append(S[i]+S[j]+S[k])
    

uni_list=list(set(li))

print(len(uni_list))

### FIXED CODE ###

N=int(input())
S=input()
s=list(S)

count=0

for i in range(1000):
    ss=s[:]
    st=str(i).rjust(3,"0")
    if st[0] in ss:
        del ss[0:ss.index(st[0])+1]
        if st[1] in ss:
            del ss[0:ss.index(st[1])+1]
            if st[2] in ss:
                count+=1

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

n = int(input())
a = list(map(int, input().split()))
#print(a)
import functools
import operator

result = functools.reduce(operator.mul, a)

if result <= 1000000000000000000:
  print(result)
else:
  print(-1)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
a.sort()
result = 1
for i in range(len(a)):
  result = result*a[i]
  if result == 0:
    break
  elif result > 1000000000000000000:
    break

if result <= 1000000000000000000:
  print(result)
else:
  print(-1)
### BUGGY CODE ###

from collections import deque

N = int(input())
A = []
for _ in range(N):
    A.append(deque(x - 1 for x in map(int, input().split())))

num_game_left = N * (N - 1) // 2
num_days = 0
while 0 < num_game_left:
    ids = [None] * N
    for i in range(N):
        if A[i]:
            ids[i] = A[i][0]
        else:
            ids[i] = None

    game_players = set()
    for i in range(N):
        if ids[i] is None:
            continue
        j = ids[i]
        if ids[j] == i:
            game_players.add(i)
            game_players.add(j)
    assert len(game_players) % 2 == 0
    num_game_left -= len(game_players) // 2

    if len(game_players) == 0:
        break

    num_days += 1
    for i in game_players:
        A[i].popleft()

if num_game_left == 0:
    print(num_days)
else:
    print(-1)

### FIXED CODE ###

N = int(input())
A = []
for _ in range(N):
    A.append([x - 1 for x in map(int, input().split())])

game = []
for p1 in range(N):
    p2 = A[p1][0]
    if A[p2][0] == p1 and p1 < p2:
        game.append((p1, p2))

cursors = [0] * N
days = 0
while game:
    days += 1
    new_game = []
    for p1, p2 in game:
        cursors[p1] += 1
        if cursors[p1] < N - 1:
            p3 = A[p1][cursors[p1]]
            if cursors[p3] < N - 1 and A[p3][cursors[p3]] == p1:
                new_game.append((p1, p3))
        cursors[p2] += 1
        if cursors[p2] < N - 1:
            p3 = A[p2][cursors[p2]]
            if cursors[p3] < N - 1 and A[p3][cursors[p3]] == p2:
                new_game.append((p2, p3))
    game = new_game

if all(c == N - 1 for c in cursors):
    print(days)
else:
    print(-1)
### BUGGY CODE ###

from operator import xor
from functools import reduce
def check(left, right):
    global A
    return reduce(xor, A[left:right])==sum(A[left:right])
N = int(input())
A = list(map(int, input().split()))
right = 0
ans = 0
for left in range(N):
    while right<N and check(left, right+1):
        right += 1
    ans += right-left
    if right==left:
        right += 1
print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
right = 0
ans = 0
A_xor = 0
A_sum = 0
for left in range(N):
    while right<N and (A_xor^A[right])==(A_sum+A[right]):
        A_xor ^= A[right]
        A_sum += A[right]
        right += 1
    ans += right-left
    if right==left:
        right += 1
    else:
        A_xor ^= A[left]
        A_sum -= A[left]
print(ans)
### BUGGY CODE ###

s=int(input())
# b=input()
# c=[]
# for i in range(b):
#     c.append(a[i])
a = list(map(int,input().split()))
#b = list(map(int,input().split()))
count=0
for i in range(s):
    for k in range(s):
        if  a[i]==a[k]:
            count+=1

if count<=s:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

s=int(input())
# b=input()
# c=[]
# for i in range(b):
#     c.append(a[i])
a = list(map(int,input().split()))
#b = list(map(int,input().split()))

c = {i for i in a}  

if len(a)==len(c):
    print("YES")
else:
    print("NO")
### BUGGY CODE ###

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

for i in a:
	ans *=i
	if(0 in a):
		print(0)
		exit()
	if(ans>1000000000000000000):
		print(-1)
		exit()
print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
ans = 1
a = sorted(a,reverse=True)
if(0 in a):
	print(0)
	exit()
for i in a:
	if(len(str(i)) + len(str(ans)) > 20):
		print(-1)
		exit()
	ans *=i

print(ans if(ans<=pow(10,18)) else -1)
### BUGGY CODE ###

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

bo = min(b,n)

ma = 0

for i in range(1,bo+1):
    s = a * i / b
    t = i / b
    ss = s // 1
    tt = (t // 1) * a
    if(ma < ss - tt):
        ma = ss - tt

print(str(int(ma)))

### FIXED CODE ###

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

def ma(k):
    s = a * k / b
    t = k / b
    ss = s // 1
    tt = (t // 1) * a
    return ss - tt

if(n < b):
    print(str(int(ma(n))))
else:
    print(str(int(ma(b-1))))
### BUGGY CODE ###

import sys,math,copy
import numpy as np
input = sys.stdin.readline
S = [int(x) if x != '?' else -1 for x in input().strip()]
N = len(S)

dp = np.zeros((13), dtype=int)
dp_ = np.zeros((13), dtype=int)
dp_[0] = 1
mod = 1
for i, s in enumerate(S[::-1], start=1):
    if s == -1:
        for d in range(10):
            m = (d * mod) % 13
            for pm in range(13):
                dp[(pm+m)%13] = (dp[(pm+m)%13] + dp_[pm]) % (10 ** 9 + 7)

    else:
        m = (s * mod) % 13
        for pm in range(13):
            dp[(pm+m)%13] = (dp[(pm+m)%13] + dp_[pm]) % (10 ** 9 + 7)
    dp_ = dp
    dp = dp * 0 # np.zeros((13), dtype=int)
    mod = (mod * 10) % 13
print(dp_[5] % (10 ** 9 + 7))

### FIXED CODE ###

import sys,math,copy

def main():
    # import numpy as np
    input = sys.stdin.readline
    S = ''.join(reversed(input().strip()))

    # dp = np.zeros((13), dtype=int)
    # dp_ = np.zeros((13), dtype=int)
    dp = [0] * 13
    dp_ = [0] * 13
    mod13_list = [i % 13 for i in range(12 ** 2 + 1)]
    list10 = list(range(10))
    list13 = list(range(13))
    divisor = 10 ** 9 + 7
    dp_[0] = 1
    mul = 1
    for i in range(len(S)):
        s = S[i]
        if s == '?':
            for d in list10:
                m = mod13_list[(d * mul)]
                for pm in list13:
                    dp[mod13_list[(pm+m)]] += dp_[pm]

        else:
            si = int(s)
            m = mod13_list[(si * mul)]
            for pm in list13:
                dp[mod13_list[(pm+m)]] = dp_[pm]

        # dp_ = dp % divisor
        # dp = dp * 0 # np.zeros((13), dtype=int)
        for j in list13:
            dp_[j] = dp[j] % divisor
            dp[j] = 0
        mul = mod13_list[(mul * 10)]
    print(dp_[5])

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

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

array = []

for t in range(10 ** 100):
    if len(array) >= n:
        break
    for p in range(a):
        array.append('blue')
    for q in range(b):
        array.append('red')

f = n // (a+b)
g = n % (a+b)

if g <= a:
    print(f * a + g)
    
else:
    print(f * (a+1))

### FIXED CODE ###

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

f = n // (a+b)
g = n % (a+b)

if g <= a:
    print(a * f + g)
    
else:
    print(a * (f+1))
### BUGGY CODE ###

import itertools
N = int(input())
L = [int(x) for x in input().split()]
c = 0
for l in itertools.combinations(L, 3):
  if sum(l) - max(l) > max(l):
    c += 1
print(c)

### FIXED CODE ###

import sys
from bisect import bisect, bisect_left

input = sys.stdin.readline
N = int(input())
L = sorted([int(x) for x in input().split()])
c = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        f = bisect_left(L, L[i] + L[j])
        c += f - j - 1
print(c)
### BUGGY CODE ###

import sys
input = sys.stdin.readline


def main():
    N = int(input())
    X = list(map(int, input().split()))
    D = [0 for i in range(N)]

    for i in range(N-1):
        D[i] = X[i+1] - X[i]

    n = 1
    for i in range(1, N):
        n *= i

    ans = 0
    r = 0
    for i in range(1, N):
        r += n // i
        ans += D[i-1] * r
        ans %= 10**9+7
    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
import math
input = sys.stdin.readline

mod = 10**9+7


def main():
    N = int(input())
    r1 = [1]
    for i in range(N-1):
        r1.append(r1[i] * (i+1) % mod)
    r2 = [1]
    for i in range(N-1):
        r2.append(r2[i] * (N-1-i) % mod)

    X = list(map(int, input().split()))
    D = [0 for i in range(N)]
    for i in range(N-1):
        D[i] = X[i+1] - X[i]

    ans = 0
    r = 0
    for i in range(N):
        r += r1[i] * r2[N-i-2]
        ans += D[i] * r
        ans %= mod
    print(ans)


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

#!/usr/bin/env python3
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main():
    N, M = map(int, readline().split())
    submit = [line.split() for line in readlines()]
    submit = [[int(p), S.decode()] for p, S in submit]
    AC_submit = [p for p, S in submit if S == 'AC']
    correct_set = set(AC_submit)
    penalty = 0
    for n in correct_set:
        p_submit = [S for p, S in submit if p == n]
        try:
            penalty += p_submit.index('AC')
        except ValueError:
            pass
    print(len(correct_set), penalty)


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main():
    N, M = map(int, readline().split())
    submit = [line.split() for line in readlines()]
    submit = [[int(p), S.decode()] for p, S in submit]
    WA_count = [0] * (N + 1)
    correct_list = [False] * (N + 1)
    correct = 0
    penalty = 0
    for p, S in submit:
        if not correct_list[p]:
            if S == 'WA':
                WA_count[p] += 1
            else:
                correct += 1
                penalty += WA_count[p]
                correct_list[p] = True
    print(correct, penalty)


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

h , n = map(int,input().split())
maho = []
for i in range(n):
    a,b = map(int,input().split())
    maho.append((a,b))
dp = [10**9 for i in range(h+1)]
for i in range(1,h+1):
    for a,b in maho:
        if i <= a:
            dp[i] = min(dp[i],b)
        elif i > a:
            dp[i] = min(dp[i],dp[i-a]+b)

print(dp[h])

### FIXED CODE ###

h , n = map(int,input().split())
maho = []
for i in range(n):
    a,b = map(int,input().split())
    maho.append((a,b))
dp = [10**8 for i in range(h+1)]
for i in range(1,h+1):
    for a,b in maho:
        if i <= a:
            dp[i] = min(dp[i],b)
        elif i > a:
            dp[i] = min(dp[i],dp[i-a]+b)

print(dp[h])
### BUGGY CODE ###

a,b,c,d=map(int,input().split())
ans = -10**9
for i in range(a,b+1):
  for j in range(c,d+1):
    ans = max(ans, i*j)

print(ans)


### FIXED CODE ###

a,b,c,d=map(int,input().split())
ans = a*c
for i in [a,b]:
  for j in [c,d]:
    ans = max(ans, i*j)

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

N,A,B = map(int,input().split())
cnt = 0
num = 0
flg = 'A'

for i in range(N):
    if flg == 'A' and num < A:
        cnt += 1
        num += 1
        if num == A:
            num = 0
            flg = 'B'
    elif flg == 'B' and num < B:
        num += 1
        if num == B:
            num = 0
            flg = 'A'
print(cnt)


### FIXED CODE ###

N, A, B = map(int, input().split())
ans = N // (A + B) * A
rem = N % (A + B)
ans += min(rem, A)
print(ans)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
 
def combi(n):
    return n*(n-1)//2
 
count_all = 0
count_cut = 0
 
 
for i in range(n):
    count = a.count(i+1)
    count_all += combi(count)
    
for k in range(n):
    #aのk番目の要素と同じ要素の数を(k番目の要素も含めて)出し、1を引く
    count = a.count(a[k]) - 1
    ans = count_all - count
    print(ans)

### FIXED CODE ###

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

num_list=[0]*n
for i in range(n):
    num_list[a[i]-1]+=1

sm_all=0
for i in range(n):
    k=num_list[i]
    sm_all+=(k*(k-1))//2

for i in range(n):
    print(sm_all-(num_list[a[i]-1]-1))
### BUGGY CODE ###

from sys import setrecursionlimit
setrecursionlimit(10**8)

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

    dp = [[[-1] * (n+1) for _ in range(n+1)] for _ in range(n+1)]
    dp[0][0][0] = 0.0

    def search(i, j, k):
        if dp[i][j][k] != -1:
            return dp[i][j][k]

        num = n
        if i > 0:
            num += search(i-1, j, k) * i
        if j > 0:
            num += search(i+1, j-1, k) * j
        if k > 0:
            num += search(i, j+1, k-1) * k
        num /= i + j + k

        dp[i][j][k] = num
        return num

    print(search(a.count(1), a.count(2), a.count(3)))

main()

### FIXED CODE ###

from sys import setrecursionlimit
setrecursionlimit(10**8)

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

    dp = [[[-1] * (n+1) for _ in range(n+1)] for _ in range(n+1)]
    dp[0][0][0] = 0.0

    def search(i, j, k):
        num = n
        if i > 0:
            if dp[i-1][j][k] == -1:
                num += search(i-1, j, k) * i
            else:
                num += dp[i-1][j][k] * i
        if j > 0:
            if dp[i+1][j-1][k] == -1:
                num += search(i+1, j-1, k) * j
            else:
                num += dp[i+1][j-1][k] * j
        if k > 0:
            if dp[i][j+1][k-1] == -1:
                num += search(i, j+1, k-1) * k
            else:
                num += dp[i][j+1][k-1] * k
        num /= i + j + k

        dp[i][j][k] = num
        return num

    print(search(a.count(1), a.count(2), a.count(3)))

main()
### BUGGY CODE ###

#!/usr/bin/env python3

def main():
    import sys
    def I(): return int(sys.stdin.readline())
    def LI(): return list(map(int,sys.stdin.readline().split()))

    n = I()
    V = []
    W = []
    for _ in range(n):
        v, w = LI()
        V.append(v)
        W.append(w)
    
    q = I()
    vl = []
    maxL = 0
    for _ in range(q):
        v, l = LI()
        maxL = max(maxL, l)
        vl.append([v,l])
    
    m = min(n, 1 << 10)
    dp = [[0]*(maxL + 1)]
    
    for i in range(1, m+1):
        v, w = V[i-1], W[i-1]
        d = [None]*(maxL + 1)
        for j in range(maxL+1):
            if j < w:
                d[j] = dp[i>>1][j]
            else:
                d[j] = max(dp[i>>1][j], dp[i>>1][j - w] + v)
        dp.append(d)

    for i in range(q):
        v, L = vl[i]
        if v <= m:
            print(dp[v][L])
            continue
        cnt = 0
        tmp = v
        v_ = []
        w_ = []
        while tmp > m:
            v_.append(V[tmp-1])
            w_.append(W[tmp-1])
            tmp >>= 1
            cnt += 1
        ret = dp[tmp][L]
        v_tmp = [0] * (1 << cnt)
        w_tmp = [0] * (1 << cnt)
        for b in range(1, 1 << cnt):
            lsb = b & -b
            l = lsb.bit_length()
            w_tmp[b] = w_tmp[b - lsb] + w_[l-1]
            if w_tmp[b] <= L:
                v_tmp[b] = v_tmp[b - lsb] + v_[l-1]
                ret = max(ret, v_tmp[b] + dp[tmp][L - w_tmp[b]])
        print(ret)
    return

if __name__ == "__main__":
    main()


### FIXED CODE ###

#!/usr/bin/env python3

def main():
    import sys
    def I(): return int(sys.stdin.readline())
    def LI(): return list(map(int,sys.stdin.readline().split()))

    n = I()
    V = []
    W = []

    maxL = 10**5
    m = min(n, 1 << 10)
    dp = [[0]*(maxL + 1)]
    
    for i in range(n):
        v, w = LI()
        if i <= m:
            d_ = dp[(i+1)>>1][:]
            for j in range(w, maxL+1)[::-1]:
                d_[j] = max(d_[j], d_[j - w] + v)
            dp.append(d_)
        V.append(v)
        W.append(w)
    
    q = I()
    for i in range(q):
        v, L = LI()
        if v <= m:
            print(dp[v][L])
            continue
        cnt = 0
        v_ = []
        w_ = []
        while v > m:
            v_.append(V[v-1])
            w_.append(W[v-1])
            v >>= 1
            cnt += 1
        ret = dp[v][L]
        v_tmp = [0] * (1 << cnt)
        w_tmp = [0] * (1 << cnt)
        for b in range(1, 1 << cnt):
            lsb = b & -b
            l = lsb.bit_length()
            w_t = w_tmp[b - lsb] + w_[l-1]
            w_tmp[b] = w_t
            if w_t <= L:
                v_t = v_tmp[b - lsb] + v_[l-1]
                v_tmp[b] = v_t
                ret = max(ret, v_t + dp[v][L - w_t])
        print(ret)
    return

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

from math import ceil
t = int(input())

for i in range(t):
    a,b,c,d = map(int, input().split())

    if a < b:
        print('No')
        continue

    if d >= b and c+1 >= b:
        print('Yes')
        continue

    A = set([a])
    while(True):
        #print(A)
        if (a-c)%b == 0:
            x = (a-c)//b
        else:
            x = ceil((a-c)/b)
        if a-b*x < 0:
            #print('No1')
            print('No')
            break
        next_a = a-b*x+d
        #print(next_a)
        if next_a < b:
            #print('No2')
            print('No')
            break
        if next_a in A:
            print('Yes')
            break
        A.add(next_a)
        if len(A) >= d:
            #print('No3')
            print('No')
            break
        a = next_a


### FIXED CODE ###

from fractions import gcd
t = int(input())

for i in range(t):
    a,b,c,d = map(int, input().split())

    if a < b or b > d:
        print('No')
        continue

    if b <= c:
        print('Yes')
        continue

    g = gcd(b, d)
    if c >= b - g + (a % g):
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

# coding: utf-8
import bisect


def solve(*args: str) -> str:
    n, m = map(int, args[0].split())
    A = sorted(map(int, args[1].split()))

    for _ in range(m):
        a = A[-1]
        A = A[0:-1]
        bisect.insort_left(A, int(a/2))

    return str(sum(A))


if __name__ == "__main__":
    print(solve(*[input() for _ in range(2)]))


### FIXED CODE ###

# coding: utf-8
import heapq


def solve(*args: str) -> str:
    n, m = map(int, args[0].split())
    A = list(map(lambda _: -int(_), args[1].split()))
    heapq.heapify(A)

    for _ in range(m):
        a = heapq.heappop(A)
        heapq.heappush(A, int(a/2))

    return str(-sum(A))


if __name__ == "__main__":
    print(solve(*[input() for _ in range(2)]))
### BUGGY CODE ###

from collections import Counter
n=int(input())
a=list(map(int,input().split()))
seta = list(set(a))

c4 = []
c2 = []
for i in seta:
  if Counter(a)[i] >= 4:
    c4.append(i)
  if Counter(a)[i] >= 2:
    c2.append(i)

c2.sort(reverse=True)
c4.sort(reverse=True)
if len(c4) == 0 and len(c2)<2:
  print(0)
elif len(c4) == 0 and len(c2)>=2:
  print(c2[0]*c2[1])
elif len(c4) > 0 and len(c2)<2:
  print(c4[0]**2)
else:
  print(max(c4[0]**2,c2[0]*c2[1]))

### FIXED CODE ###

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

e=[]
a.sort(reverse=True)
for i in range(len(a)-1):
  if a[i] == a[i+1] and a[i] not in e:
    e.append(a[i])
    if len(e) == 2:
      break
e.sort(reverse=True)

c4 = 0
for i in e:
  if a.count(i)>=4:
    c4=i
    break

if c4 == 0 and len(e)<2:
  print(0)
elif c4 == 0 and len(e)>=2:
  print(e[0]*e[1])
elif c4 > 0 and len(e)<2:
  print(c4**2)
else:
  print(max(c4**2,e[0]*e[1]))
### BUGGY CODE ###

R, G, B, N = map(int, input().split())
ans = [0 for r in range(N//R + 1) for g in range((N - (r*R))//G + 1) for b in range((N-(r * R + g * G))//B + 1) if  r*R + g*G + b*B == N]
print(len(ans))

### FIXED CODE ###

import sys
R, G, B, N = map(int, sys.stdin.readline().split())
print(len([0 for r in range(N//R + 1) for g in range((N - (r*R))//G + 1) if  (N -(r*R + g*G))%B == 0]))