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

# 繰り返し二乗法 (mod 有り)
def mod_rep_pow(a, n, mod=(10 ** 9 + 7)):
    res = 1
    while n > 0:
        if n % 2 == 0:
            a = a ** 2 % mod
            n //= 2
        else:
            res = res * a % mod
            n -= 1
    return (res % mod)


# 繰り返し二乗法 (mod 有り) を利用して nCk を高速に返す
# mod が素数のときのみ利用可能 (フェルマーの小定理を利用しているため)
def mod_comb(n, k, mod=(10 ** 9 + 7)):
    res1 = 1
    for i in range(n, (n - k), -1):
        res1 *= i
        res1 %= mod
    res2 = 1
    for i in range(1, (k + 1)):
        res2 *= i
        res2 %= mod
    return ((res1 * mod_rep_pow(res2, (mod - 2), mod)) % mod)


n = int(input().strip())
a = list(map(int, input().split()))
b = {}
length = -1
for i in range(n + 1):
    if b.get(a[i]) is None:
        b[a[i]] = i
    else:
        length = i - b[a[i]]
        break
x = n - length
for i in range(1, n + 2):
    print(mod_comb(n + 1, i) - mod_comb(x, (i - 1)))


### FIXED CODE ###

def mod_rep_pow(a, n, mod=(10 ** 9 + 7)):
    res = 1
    while 0 < n:
        if n & 1:
            res = (res * a) % mod
            n -= 1
        else:
            a = (a ** 2) % mod
            n //= 2
    return (res % mod)


def mod_inverse(a, mod=(10 ** 9 + 7)):
    return mod_rep_pow(a, (mod - 2))


def mod_comb(facts, facts_inverse, n, k, mod=(10 ** 9 + 7)):
    return (facts[n] * facts_inverse[k] * facts_inverse[n - k])


n = int(input().strip())
a = list(map(int, input().split()))
not_unique = sum(a) - sum([i for i in range(1, n + 1)])
b = []
for i in range(n + 1):
    if a[i] == not_unique:
        b.append(i)
x = n - (b[1] - b[0])
mod = 10 ** 9 + 7
facts = [1] * (n + 2)
for i in range(0, n + 1):
    facts[i + 1] = (facts[i] * (i + 1) % mod)

facts_inverse = [1] * (n + 2)
facts_inverse[n + 1] = mod_inverse(facts[n + 1])
for i in range(n + 1, 0, -1):
    facts_inverse[i - 1] = (facts_inverse[i] * (i)) % mod

for i in range(1, n + 2):
    if x < (i - 1):
        print(mod_comb(facts, facts_inverse, (n + 1), i) % mod)
    else:
        print((mod_comb(facts, facts_inverse, (n + 1), i) - (mod_comb(facts, facts_inverse, x, (i - 1)))) % mod)
### BUGGY CODE ###

N=int(input())
list1=[]
L=list(map(int,input().split()))
L.sort(reverse=True)
cnt=1
for i in range(N-1):
    if L[i]!=L[i+1]:
        list1.append([L[i],L.count(L[i])])
list1.append([L[len(L)-1],L.count(L[len(L)-1])])
#print(list1)     
H=0
i=0
for i in range(len(list1)):
    if list1[i][1]>=4:
        if H==0:
            print(list1[i][0]**2)
            exit()
        else:
            print(H*list1[i][0])
            exit()
    elif list1[i][1]>=2:
        if H==0:
            H=list1[i][0]
        else:
            print(H*list1[i][0])
            exit()
print(0)

### FIXED CODE ###

from collections import Counter
N=int(input())
A=list(map(int,input().split()))
B=Counter(A)
#print(B)      
C=list(B.items())
C.sort(reverse=True)
#print(C)

H=0
W=0
for i in range(len(C)):
    if H==0:
        if C[i][1]>=4:
            print(C[i][0]**2)
            exit()
        elif C[i][1]>=2:
            H=C[i][0]
    else:
        if C[i][1]>=2:
            print(H*C[i][0])
            exit()
print(0)
### BUGGY CODE ###

n,k=map(int,input().split())
p=list(map(int,input().split()))
if n==k:
    print((sum(p)+k)/2)
else:
    ans=(sum(p[:k])+k)/2
    for i in range(1,n-k+1):
        ans=max(ans,(sum(p[i:k+i])+k)/2)
    print(ans)

### FIXED CODE ###

n,k=map(int,input().split())
p=list(map(int,input().split()))
if n==k:
    print((sum(p)+k)/2)
else:
    ans=(sum(p[:k])+k)/2
    res=ans
    for i in range(n-k):
        res+=(p[k+i]-p[i])/2
        ans=max(ans,res)
    print(ans)
### BUGGY CODE ###

if __name__ == '__main__':
    n = int(input())
    a = [int(i) for i in input().split()]
    ans = [0]*n
    for i in range(n):
        ans[a[i]-1] = i+1
    ans_str =""
    for i in ans:
        if ans_str =="":
            ans_str = str(i)
        else:
            ans_str = ans_str+" "+str(i)
    print(ans_str)

### FIXED CODE ###

if __name__ == '__main__':
    n = int(input())
    a = [int(i) for i in input().split()]
    ans = [0]*n
    for i in range(n):
        ans[a[i]-1] = i+1
    ans_list = map(str, ans)  # mapで要素すべてを文字列に
    ans_str =' '.join(ans_list)
    print(ans_str)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
mod = 7 + 10**9
A = []
leng = len(format(max(a), 'b'))
bit_acc = [0 for i in range(leng)]
for i in range(n):
    A.append(list(map(int, format(a[i], 'b').zfill(leng))))
for i in range(leng):
    bit_acc[i] = sum([A[j][i] for j in range(n)]) 
ans = 0
p = [pow(2,leng - j - 1,mod) for j in range(leng)]
for i in range(n):
    for j in range(leng):
        if A[i][j] == 1:
            ans += (n - bit_acc[j]) * p[j]
        else:
            ans += bit_acc[j] * p[j]
        ans %= mod
print((ans * 500000004) % mod)



### FIXED CODE ###

def main():
    import sys
    input = sys.stdin.readline
    n = int(input())
    a = list(map(int, input().split()))
    a.reverse()
    mod = 7 + 10**9
    leng = len(format(max(a), 'b'))
    bit_acc = [0 for i in range(leng)]
    for i in range(n):
        #先頭から二進数を0埋めした
        bit_data = format(a[i], 'b').zfill(leng)
        for j in range(leng):
            if bit_data[j] == '1':
                bit_acc[j] += 1
    ans = 0
    p = [pow(2,leng - 1 - j, mod) for j in range(leng)]
    for i in range(n):
        bit_data = format(a[i], 'b').zfill(leng)
        for j in range(leng):
            if bit_data[j] == '1':
                ans += (n - bit_acc[j]) * p[j]
            else:
                ans += bit_acc[j] * p[j]
            ans %= mod
    print((ans * 500000004) % mod)
if __name__ == "__main__":
    main()
### BUGGY CODE ###

n = int(input())
l = list(map(int, input().split()))
arr = []
ans = []
ans = []
cnt = []
already = []
for index, i in enumerate(l):
    if l.count(i) >= 2:
        arr.append(i)
if len(arr) == 0:
    print(0)
else:
    for i in arr:
        if i not in already:
            already.append(i)
            cnt.append(arr.count(i))
    for i in range(len(already)):
        for j in range(i, len(already)):
            if i == j and cnt[i] >= 4:
                ans.append(already[i] ** 2)
            elif i != j:
                ans.append(already[i] * already[j])
    print(max(ans))

### FIXED CODE ###

n = int(input())
a = list(map(int , input().split()))
ans = []
a.sort()
a.reverse()
f = 0
cnt = 1
when = 0
for i in a:
    if i == f:
        cnt += 1
        if cnt >= 2:
            ans.append(i)
            cnt = 0
            when += 1
    else:
        f = i
        cnt = 1
    if when == 2:
        break
if len(ans) != 0:
    print(ans[0] * ans[1])
else:
    print(0)
### BUGGY CODE ###

H, W, D = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
Q = int(input())
LR = [list(map(int, input().split())) for _ in range(Q)]
num_pos = {}

for y, line in enumerate(A):
    for x, num in enumerate(line):
        num_pos[num] = (x, y)

cost_table = {i: {} for i in num_pos.keys()}
for num1 in sorted(num_pos.keys()):
    for num2 in range(num1, H*W+1, D):
        if num1 == num2:
            cost_table[num1][num2] = 0
        else:
            i, j = num_pos[num2-D]
            x, y = num_pos[num2]
            cost_table[num1][num2] = abs(i - x) + abs(j - y) + cost_table[num1][num2-D]

for l, r in LR:
    print(cost_table[l][r])

### FIXED CODE ###

import sys
Input = sys.stdin.readline

H, W, D = map(int, Input().split())
A = [list(map(int, Input().split())) for _ in range(H)]
Q = int(Input())
LR = [list(map(int, Input().split())) for _ in range(Q)]
num_pos = {}

for y, line in enumerate(A):
    for x, num in enumerate(line):
        num_pos[num] = (x, y)

cost_table = {}
for num in range(1, H*W+1):
    if num <= D:
        cost_table[num] = 0
    else:
        i, j = num_pos[num-D]
        x, y = num_pos[num]
        cost_table[num] = abs(i - x) + abs(j - y) + cost_table[num-D]

for l, r in LR:
    print(cost_table[r] - cost_table[l])
### BUGGY CODE ###

def solve(N, W, weightValues):
    dp = [0] * (W + 1)
    for item in range(1, N + 1):
        w, v = weightValues[item - 1]
        for i in range(W, w - 1, -1):  #
            dp[i] = max(dp[i], v + dp[i - w])

    print(max(dp))


N, W = map(int, input().split())
weightValues = sorted([list(map(int, input().split())) for i in range(N)])
solve(N, W, weightValues)

### FIXED CODE ###


N,W=map(int,input().split())
dp=[0]*(W+1)
L = sorted([list(map(int,input().split())) for i in range(N)])
s=0
 
for w, v in L:
    s+=w
    for j in range(min(W,s),w-1,-1):
        if dp[j-w]+v > dp[j]: dp[j]=dp[j-w]+v
    
print(max(dp))
### BUGGY CODE ###

N = int(input())
S = input()
R = [0]*N
G = [0]*N
B = [0]*N
ans = 0
for i in range(N):
    R[i] = R[i-1]
    G[i] = G[i-1]
    B[i] = B[i-1]
    if S[i] == 'R':
        R[i] += 1
    elif S[i] == 'G':
        G[i] += 1
    else:
        B[i] += 1
for i in range(N):
    for k in range(i,N):
        if (S[i] != S[k]) and (S[i] != 'R' and S[k] != 'R'):
            ans += R[N-1] - R[k]
            if k+(k-i) < N and S[k+(k-i)] == 'R':
                ans -= 1
        if (S[i] != S[k]) and (S[i] != 'G' and S[k] != 'G'):
            ans += G[N-1] - G[k]
            if k+(k-i) < N and S[k+(k-i)] == 'G':
                ans -= 1
        if (S[i] != S[k]) and (S[i] != 'B' and S[k] != 'B'):
            ans += B[N-1] - B[k]
            if k+(k-i) < N and S[k+(k-i)] == 'B':
                ans -= 1
print(ans)

### FIXED CODE ###

N = int(input())
S = input()
R = [0]*N
G = [0]*N
B = [0]*N
ans = 0
for i in range(N):
    R[i] = R[i-1]
    G[i] = G[i-1]
    B[i] = B[i-1]
    if S[i] == 'R':
        R[i] += 1
    elif S[i] == 'G':
        G[i] += 1
    else:
        B[i] += 1
for i in range(N):
    for k in range(i,N):
        if (S[i] != S[k]) and (S[i] != 'R' and S[k] != 'R'):
            ans += R[N-1] - R[k]
            if k+(k-i) < N and S[k+(k-i)] == 'R':
                ans -= 1
        if (S[i] != S[k]) and (S[i] != 'G' and S[k] != 'G'):
            ans += G[N-1] - G[k]
            if k+(k-i) < N and S[k+(k-i)] == 'G':
                ans -= 1
        if (S[i] != S[k]) and (S[i] != 'B' and S[k] != 'B'):
            ans += B[N-1] - B[k]
            if k+(k-i) < N and S[k+(k-i)] == 'B':
                ans -= 1
print(ans)
### BUGGY CODE ###

from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

s = input()
ss = [i for i in s[::-1]]
rem = [0] * 13
rem[0] = 1
for i, st in enumerate(ss):
    if st == '?':
        tmp = rem[:]
        rem = [0] * 13
        for j in range(10):
            next = (j * 10 ** i) % 13
            for k in range(13):
                rem[(k+next)%13] += tmp[k]
    else:
        next = (int(st) * 10**i) % 13
        tmp = rem[:]
        for j in range(13):
            rem[(j+next)%13] = tmp[j]
print(rem[5] % mod)

### FIXED CODE ###

from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

s = sys.stdin.readline()
n = len(s)-1
now = [0] * 13
now[0] = 1
for i in range(n)[::-1]:
    prev = now[::]
    now = [0] * 13
    c = n - i - 1#桁
    m = pow(10,c,13)
    if s[i] == '?':
        for k in range(10):
            l = (m*k) % 13
            for j in range(13):
                now[(j+l)%13] += prev[j]
                now[(j+l)%13] = now[(j+l)%13] % mod
    else:
        k = int(s[i])
        l = (m*k) % 13
        for j in range(13):
            now[(j+l)%13] = prev[j]
    # print(now)
print(now[5])
### BUGGY CODE ###

import sys
input = sys.stdin.readline
n, m = map(int,input().split())
a = list(map(int,input().split()))
a.sort(reverse=True)
for k in range(m):
  s, t = map(int,input().split())
  if a[n-1] < t:
    for i in range(n):
      if a[n-i-1] >= t:
        a[n-i:n-i] = [t]*s
        break
      elif i + 1 == n:
        a[0:0] = [t]*s
ans = 0
for v in range(n):
  ans += a[v]
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline
n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
b = [list(map(int,input().split())) for p in [0]*m]
b.sort(key=lambda q: -q[1])
#print(a)
#print(b)

c = 0
for s in b:
	for t in [0]*s[0]:
		#print(s)
		if c + 1 > n:
			break
		if s[1] <= a[c]:
			break
		a[c] = s[1]
		c += 1
		#print(a)
	else:
		continue
	break
print(sum(a))
### BUGGY CODE ###

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

ans = 0

b = [0]
for i in range(n):
    b.append(b[i] + a[i])
for x in list(set(b)):
    b_num = b.count(x)
    ans += sum([i for i in range(b_num)])
    
print(ans)

### FIXED CODE ###

from collections import Counter

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

ans = 0

b = [0]
for i in range(n):
	b.append(b[i] + a[i])

c = Counter(b)

for value in c.values():
	ans += value * (value - 1) // 2
    
print(ans)
### BUGGY CODE ###

from sys import stdin
n = input().split(' ')
c = 0
K = n[0]
S = n[1]
for i in range(int(K)+1):
    for j in range(int(K)+1):
        for k in range(int(K)+1):
            sum=i+j+k
            if sum is int(S):
                c += 1
                break
                
print(c)

### FIXED CODE ###

k,s=map(int,input().split())
ans=0
for x in range(k+1):
    for y in range(k+1):
        z=s-x-y
        if 0<=z<=k:
            ans+=1
print(ans)
### BUGGY CODE ###

n, m = input().split()
n = int(n)
m = int(m)
 
result_list = []
true_flag = False
ac_list = []

for i in range(m):
    a,b=input().split()
    result_list.append((int(a), b))
    if b == "AC":
        true_flag = True
        if a in ac_list:
            pass
        else:
            ac_list.append(a)

# 正解した問題を入れるlist
done_list = []
pn_list = [0] * n
correct = 0
pn = 0
 
if true_flag == False:
    print(0, 0)
else: 
    for result in result_list:
        if result[0] in done_list:
            pass
        elif result[1] == "WA":
            pn_list[result[0] - 1] += 1

        elif result[1] == "AC":
            done_list.append(result[0])
            correct += 1
            pn += pn_list[result[0] - 1]
        if len(done_list) == len(ac_list):
            break
    
    print(correct, pn)

### FIXED CODE ###

n, m = input().split()
n = int(n)
m = int(m)

# 正解した問題を入れるlist

correct = 0
pn = 0
done_list = [0] * n
pn_list = [0] * n

for i in range(m):
    a,b=input().split()
    
    if done_list[int(a)-1] == 0 and b == "AC":
        done_list[int(a)-1] += 1
        correct += 1
        pn += pn_list[int(a) - 1]
    elif b == "WA":
        pn_list[int(a) - 1] += 1

print(correct, pn)
### BUGGY CODE ###

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

def lower(i, H):
  cnt = 0
  while H[i] >= H[i+1]:
    cnt += 1; i += 1;
    if i+1 > N-1:
      break
  return cnt

ans = 0
for i in range(N-1):
  tmp = lower(i, H)
  ans = max(ans, tmp)
  i += tmp

print(ans)

### FIXED CODE ###

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

def lower(i, H):
  cnt = 0
  while H[i] >= H[i+1]:
    cnt += 1; i += 1;
    if i+1 > N-1:
      break
  return cnt

ans, i = 0, 0
while i < N - 1:
  tmp = lower(i, H)
  ans = max(ans, tmp)
  i += tmp+1

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

s = input()
q = int(input())

t = 0
for _ in range(q):
  query = list(input().split())
  query[0] = int(query[0])
  if query[0] == 1: t = 1 - (t)
  else:
    if t == 0:
      if int(query[1]) == 1: s = query[2]+s
      else: s += query[2]
    else:
      if int(query[1]) == 1: s += query[2]
      else: s = query[2]+s
if t == 0: print(s)
else: print(s[::-1])

### FIXED CODE ###

from collections import deque
s = deque(list(input()))
q = int(input())

rev = 0
for i in range(q):
  tfc = list(input().split())
  if tfc[0] == "1":
    rev = abs(rev-1)
  else:
    t,f,c = tfc
    if rev:
      if f == "1":
        s.append(c)
      else:
        s.appendleft(c)
    else:
        if f == "1":
          s.appendleft(c)
        else:
          s.append(c)
if rev:
  t = []
  for i in range(len(s)):
    t.append(s.pop())
  print("".join(t))
else:
  print("".join(s))
### BUGGY CODE ###


def knapSack(W, wt, val, n): 
	K = [[0 for x in range(W+1)] for x in range(n+1)] 

	
	for i in range(n+1): 
		for w in range(W+1): 
			if i==0 or w==0: 
				K[i][w] = 0
			elif wt[i-1] <= w: 
				K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]], K[i-1][w]) 
			else: 
				K[i][w] = K[i-1][w] 

	return K[n][W] 




q=list(map(int,input().split()))
n=q[0]
W=q[1]
v=[0]*n
w=[0]*n
for _ in range(n):
  r=list(map(int,input().split()))
  w[_]=r[0]
  v[_]=r[1]
  




print(knapSack(W,w,v,n))


### FIXED CODE ###

def knapSack(W, wt, val, n): 
	K = [[0 for x in range(W+1)] for x in range(n+1)] 

	
	for i in range(n+1): 
		for w in range(W+1): 
			if i==0 or w==0: 
				K[i][w] = 0
			elif wt[i-1] <= w: 
				K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]], K[i-1][w]) 
			else: 
				K[i][w] = K[i-1][w] 

	return K[n][W] 




q=list(map(int,input().split()))
n=q[0]
W=q[1]
v=[0]*n
w=[0]*n
for _ in range(n):
  r=list(map(int,input().split()))
  w[_]=r[0]
  v[_]=r[1]
  




print(knapSack(W,w,v,n))
### BUGGY CODE ###

import sys
from operator import itemgetter
import heapq
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
xy = [IL() + [i] for i in range(N)]

xroot = [[] for _ in range(N+1)]
yroot = [[] for _ in range(N+1)]

xlist = sorted(xy, key=itemgetter(0)) # [x, y, ID]
ylist = sorted(xy, key=itemgetter(1))
for i in range(N-1):
  x, hoge, xID = xlist[i]
  nextx, hoge, nextxID = xlist[i + 1]
  costx = abs(x - nextx)
  xroot[xID].append([costx, nextxID])
  xroot[nextxID].append([costx, xID])

  hoge, y, yID = ylist[i]
  hoge, nexty, nextyID = ylist[i + 1]
  costy = abs(y - nexty)
  yroot[yID].append([costy, nextyID])
  yroot[nextyID].append([costy, yID])
#print(xroot) # [cost, rootID]
#print(yroot)

hpop = heapq.heappop
hpush = heapq.heappush
data = [] # [val, ID]

visited = [False]*(N+1)
hpush(data, [0, 0])
ans = 0
while data:
  val, num = hpop(data)
  if visited[num] == False:
    visited[num] = True
    #print(val, num)
    ans += val
    for i in xroot[num]:
      if visited[i[1]] == False:
        hpush(data, i)
    for j in yroot[num]:
      if visited[j[1]] == False:
        hpush(data, j)
print(ans)

### FIXED CODE ###

import sys
from operator import itemgetter
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def init(n):
  for i in range(N):
    par[i]=i
    rnk[i]=0
def find(x):
  if par[x]==x:
    return x
  else:
    par[x]=find(par[x])
    return par[x]
def unite(x,y):
  x=find(x)
  y=find(y)
  if x==y:
    return
  if (rnk[x]<rnk[y]):
    par[x]=y
  else:
    par[y]=x
    if(rnk[x]==rnk[y]):
      rnk[x]+=1
def same(x,y):
    return find(x)==find(y)

N = I()
xlist = []
ylist = []

par=[0 for i in range(N)]
rnk=[0 for i in range(N)]
init(N)

for i in range(N):
  x, y = IL()
  xlist.append([x, i])
  ylist.append([y, i])
xlist.sort(key=itemgetter(0))
ylist.sort(key=itemgetter(0))

node = []
for i in range(N-1):
  x, xID = xlist[i]
  nextx, nextxID = xlist[i + 1]
  y, yID = ylist[i]
  nexty, nextyID = ylist[i + 1]
  
  node.append([nextx - x, xID, nextxID])
  node.append([nexty - y, yID, nextyID])
node.sort(key=itemgetter(0), reverse=True)

ans = 0
while node:
  val, i, j = node.pop()
  if same(i, j):
    continue
  else:
    unite(i, j)
    ans += val
print(ans)
### BUGGY CODE ###

n, m = map(int, input().split())
a_list = list(map(int, input().split()))
m_list = []
cnt = 0
for _ in range(m):
    b, c = map(int, input().split())
    m_list += [c]*b
    cnt += b
if cnt < n:
    m_list += [0]*(n-cnt)
a_list.sort()
m_list.sort(reverse=True)
ans = 0
for a, m in zip(a_list, m_list):
    ans += max(a, m)
print(ans)


### FIXED CODE ###

import sys

input = sys.stdin.readline
n, m = map(int, input().split())
a_list = list(map(int, input().split()))
m_list = []
for _ in range(m):
    b, c = map(int, input().split())
    m_list.append([c, b])
m_list.sort(reverse=True)
cnt = 0
tmp_list = []
for c, b in m_list:
    if cnt < n:
        tmp_list += [c]*b
    else:
        break
    cnt += b
a_list.extend(tmp_list)
a_list.sort(reverse=True)
print(sum(a_list[:n]))
### BUGGY CODE ###

import re
N, Q = map(int, input().split())
S=input()
lr=[]
for _ in range(Q):
    lr.append(tuple(map(int, input().split())))
#print(N, Q, S, lr)

ACs=[m.start()+1 for m in re.finditer('AC', S)]
#print(ACs)

for val in lr:
    OK=[strt for strt in ACs if val[0] <= strt and strt + 1 <= val[1]]
    print(len(OK))


### FIXED CODE ###

import re
N, Q = map(int, input().split())
S=input()
lr=[]
for _ in range(Q):
    lr.append(tuple(map(int, input().split())))
#print(N, Q, S, lr)



accum=[0]*(N+1)
should_plus=0
for i in range(2, N+1):
    if S[i-2]=='A' and S[i-1]=='C':
        should_plus+=1
    accum[i]=should_plus
#print(accum)

for val in lr:
    OK=accum[val[1]]-accum[val[0]-1]
    if S[(val[0]-2):val[0]]=='AC':
        OK-=1
    print(OK)
### BUGGY CODE ###

def LI():
    return list(map(int, input().split()))

_ = int(input())
a = LI()
ans = 1
mod = pow(10, 18)

def main(ans):
    for i in a:
        ans *= i
        if ans == 0:
            break
    if ans > mod:
        ans = -1
    print(ans)


if __name__ == "__main__":
    main(ans)

### FIXED CODE ###

def LI():
    return list(map(int, input().split()))

_ = int(input())
a = LI()
ans = 1
mod = pow(10, 18)

def main(ans):
    if 0 in a:
        ans = 0
    else:
        for i in a:
            ans *= i
            if ans > mod:
                ans = -1
                break
    print(ans)

if __name__ == "__main__":
    main(ans)