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

from itertools import accumulate
R, C, K = map(int, input().split())
vss = [[None]*C for _ in range(R)]
for _ in range(K):
    r, c, v = map(int, input().split())
    vss[r-1][c-1] = v

dp = []

for y in range(R):
    nowdp = []
    dp.append(nowdp)
    for x in range(C):
        tmp = []
        uemax = 0
        if y > 0:
            uemax = max(dp[y-1][x])
        if vss[y][x] is None:
            if x > 0:
                tmp.append(max(dp[y][x-1][0], uemax))
                tmp.append(dp[y][x-1][1])
                tmp.append(dp[y][x-1][2])
                tmp.append(dp[y][x-1][3])
            else:
                tmp.append(uemax)
                tmp.append(0)
                tmp.append(0)
                tmp.append(0)
        else:
            v = vss[y][x]
            if x > 0:
                tmp.append(max(dp[y][x-1][0], uemax))
                tmp.append(max(dp[y][x-1][0]+v, dp[y][x-1][1], uemax+v))
                tmp.append(max(dp[y][x-1][1]+v, dp[y][x-1][2]))
                tmp.append(max(dp[y][x-1][2]+v, dp[y][x-1][3]))
            else:
                tmp.append(uemax)
                tmp.append(uemax + v)
                tmp.append(0)
                tmp.append(0)
        nowdp.append(tmp)

print(max(dp[R-1][C-1]))


### FIXED CODE ###

from itertools import accumulate
R, C, K = map(int, input().split())
vss = [[None]*C for _ in range(R)]
for _ in range(K):
    r, c, v = map(int, input().split())
    vss[r-1][c-1] = v

dp = []

for y in range(R):
    ndp = []
    for x in range(C):
        tmp = []
        uemax = 0
        if y > 0:
            uemax = max(dp[x])
        if vss[y][x] is None:
            if x > 0:
                left = ndp[-1]
                tmp.append(left[0] if left[0] > uemax else uemax)
                tmp.append(left[1])
                tmp.append(left[2])
                tmp.append(left[3])
            else:
                tmp.append(uemax)
                tmp.append(0)
                tmp.append(0)
                tmp.append(0)
        else:
            v = vss[y][x]
            if x > 0:
                left = ndp[-1]
                tmp.append(left[0] if left[0] > uemax else uemax)
                tmp.append(max(left[0]+v, left[1], uemax+v))
                tmp.append(left[1]+v if left[1]+v > left[2] else left[2])
                tmp.append(left[2]+v if left[2]+v > left[3] else left[3])
            else:
                tmp.append(uemax)
                tmp.append(uemax + v)
                tmp.append(0)
                tmp.append(0)
        ndp.append(tmp)
    dp = ndp

print(max(dp[-1]))
### BUGGY CODE ###

#!/usr/bin/env python3


def main():
    N = int(input())
    As = [int(input()) for _ in range(N)]
    for i in range(N):
        tmp = As[:]
        tmp.pop(i)
        print(max(tmp))


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3


def main():
    N = int(input())
    As = [int(input()) for _ in range(N)]
    max1 = max(As)
    max_idx = As.index(max1)
    As.remove(max1)
    max2 = max(As)
    max_list = [max1] * N
    max_list[max_idx] = max2
    for m in max_list:
        print(m)


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

import sys
input=sys.stdin.readline
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#N = int(input())
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = list(map(int,input().split()))
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
N,M = map(int,input().split())
A = [int(input()) for _ in range(M)]  
ans = [0] * (N+3)
ans[0] = 1
for i in range(N):
    if (i+1) not in A:
        ans[i+1] += ans[i]
        ans[i+1] = ans[i+1] % 1000000007
    if (i+2) not in A:
        ans[i+2] += ans[i]
        ans[i+2] = ans[i+2] % 1000000007
print(ans[N])

### FIXED CODE ###

import sys
input=sys.stdin.readline
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#N = int(input())
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = list(map(int,input().split()))
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
N,M = map(int,input().split())
dicti = {i:True for i in range(N+2)}
for i in range(M):
    a = int(input())
    dicti[a] = False
ans = [0] * (N+3)
ans[0] = 1
for i in range(N):
    if dicti[i]:
        ans[i+1] += ans[i]
        ans[i+1] = ans[i+1] % 1000000007
        ans[i+2] += ans[i]
        ans[i+2] = ans[i+2] % 1000000007
    else:
        ans[i] = 0
print(ans[N])
### BUGGY CODE ###

N, X, Y = list(map(int, input().split()))
neighbor = { i: [] for i in range(1, N+1) }
for i in range(1,N):
    neighbor[i].append(i+1)
    neighbor[N-i+1].append(N-i)
neighbor[X].append(Y)
neighbor[Y].append(X)

distanced_neighbor = { i: { j: [] for j in range(1, N)} for i in range(1, N+1) }
for i in range(1, N+1):
    visited = [i]
    next_nodes = neighbor[i]
    for j in range(1, N):
        distanced_neighbor[i][j] = next_nodes[:]
        queue = next_nodes[:]
        visited += next_nodes
        next_nodes = []
        for q in queue:
            for node in neighbor[q]:
                if node in visited:
                    continue
                else:
                    next_nodes.append(node)
        next_nodes = list(set(next_nodes))

for i in range(1, N):
    print(sum([len(distanced_neighbor[j][i]) for j in range(1, N+1)])//2)
    

### FIXED CODE ###

def min_dist(i, j, X, Y):
    return min(abs(j-i), abs(X-1-i)+1+abs(Y-1-j), abs(Y-1-i)+1+abs(X-1-j))

N, X, Y = list(map(int, input().split()))
dists = [min_dist(i, j, X, Y) for i in range(N-1) for j in range(i+1, N)]
dist_dic = { i: 0 for i in range(1,N)}
for dist in dists:
    dist_dic[dist] += 1
for K in range(1,N):
    print(dist_dic[K])
### BUGGY CODE ###

import numpy as np
from collections import deque

N,M,X = [int(i) for i in input().split()]
A = np.array([[int(i) for i in input().split()]])
for _ in range(N-1):
    B = np.array([int(i) for i in input().split()])
    A = np.vstack([A, B])

m = min([np.sum(A[:,i:i+1]) for i in range(1,M+1)])
if m < X:
    print(-1)
    exit()

ans = np.sum(A[:,0:1])
q = deque([[i] for i in range(N)])
while len(q) != 0:
    L = q.pop()
    L.sort(reverse=True)
    B = A.copy()
    for i in L:
        B = np.delete(B, i, 0)
    m = min([np.sum(B[:,i:i+1]) for i in range(1,M+1)])
    if m < X:
        continue
    ans = min([ans,np.sum(B[:,0:1])])
    for i in range(N):
        L1 = L.copy()
        L1.append(i)
        L1set = set(L1)
        if len(L) < len(L1set):
            q.appendleft(L1)

print(ans)

### FIXED CODE ###

N,M,X = [int(i) for i in input().split()]
A = []
for _ in range(N):
    A.append([int(i) for i in input().split()])
ans = float("inf")

for i in range(1,2**N):
    a = 0
    e = [0]*M
    bi = "0"*N + bin(i)[2:]
    bi = list(bi[len(bi)-N:])
    for j in range(N):
        if bi[j] == "1":
            a += A[j][0]
            for k in range(M):
                e[k] += A[j][k+1]
    c = True
    for i in range(M):
        c &= e[i] >= X
    if c:
        ans = min(ans,a)
if ans > 10**7:
    print(-1)
else:
    print(ans)
### BUGGY CODE ###

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

for i in range(q):
    query = list(input().split())
    if len(query) == 1:
        s = ''.join(list(reversed(s)))
    elif query[1] == '1':
        s = query[2] + s
    elif query[1] == '2':
        s = s + query[2]
        
print(s)
        

### FIXED CODE ###

from sys import stdin
input = stdin.readline

s = input().rstrip()
q = int(input())

isRev = False

head = ''

for i in range(q):
    query = list(input().split())
    if len(query) == 1:
        isRev = not isRev
    else:
        if isRev and query[1] == '1':
            s = s + query[2]
        elif query[1] == '1':
            head = head + query[2]
        elif isRev and query[1] == '2':
            head = head + query[2]
        elif query[1] == '2':
            s = s + query[2]
            
if isRev:
    s = s[::-1] + head
else:
    s = head[::-1] + s
        
print(s)
### BUGGY CODE ###

#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N, K = map(int, input().split())
    h = list(map(int, input().split()))
    INF = 10**10
    #dp[i]　iの位置に到達する最小の値
    dp = [INF]*N
    dp[0] = 0
    for i in range(N):
        for k in range(1, K+1):
            if (i+k)<N:
                dp[i+k] = min(dp[i+k], dp[i] + abs(h[i+k]-h[i]))
    print(dp[N-1])

if __name__ == '__main__':
    main()

### FIXED CODE ###

N, K = map(int,input().split())
H = list(map(int,input().split()))
import numpy as np
dp = np.zeros(N,dtype=np.int)
harr = np.array(H)
for i in range(1,N):
  St = max(0,i-K)
  Hi = harr[i]
  dp[i] = min(dp[max(0,i-K):i] + np.abs(Hi - harr[max(0,i-K):i]))
print(dp[-1])
### BUGGY CODE ###

import sys
input = sys.stdin.readline

def main():
    n = int(input())
    a = list(map(int, input().split()))
    s = [0]*(n+1)

    for i in range(n):
        s[i+1] += s[i] + a[i]
    
    ans = int(1e15)
    for i in range(n):
        sub = []
        for l, r, ll, rr in zip([0, i], [i, n], [0, i], [i, n]):
            while r-l > 1:
                k = (r+l) // 2
                if s[k] - s[ll] < s[rr] - s[k]:
                    l = k
                else:
                    r = k

            if abs(s[ll] + s[rr] - s[l]*2) > abs(s[ll] + s[rr] - s[r]*2):
                k = r
            else:
                k = l
            sub.append(s[k] - s[ll])
            sub.append(s[rr] - s[k])
        judge = max(sub) - min(sub)
        ans = min(ans, judge)
    
    print(ans)


    
if __name__ == "__main__":
    main()



### FIXED CODE ###

import sys
input = sys.stdin.readline

def main():
    n = int(input())
    a = list(map(int, input().split()))
    s = [0]*(n+1)

    for i in range(n):
        s[i+1] += s[i] + a[i]
    
    ans = int(1e15)
    for i in range(n):
        sub = []
        for l, r, ll, rr in zip([0, i], [i, n], [0, i], [i, n]):
            while r-l > 1:
                k = (r+l) // 2
                if s[k] - s[ll] < s[rr] - s[k]:
                    l = k
                else:
                    r = k

            if abs(s[ll] + s[rr] - s[l]*2) > abs(s[ll] + s[rr] - s[r]*2):
                k = r
            else:
                k = l
            sub.append(s[k] - s[ll])
            sub.append(s[rr] - s[k])
        judge = max(sub) - min(sub)
        ans = min(ans, judge)
    
    print(ans)


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

s,c=map(int,input().split())
count=0

while s>=1 and c>=2:
  count+=1
  s-=1
  c-=2

while c>=4:
  count+=1
  c-=4
  
print(count)

### FIXED CODE ###

import math

s,c=map(int,input().split())

if s*2>c:
  print(int(c/2))

else:
  count=s
  c-=s*2
  count+=math.floor(c/4)
  print(count)
### BUGGY CODE ###

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

sep = []
flg = 0

for i in range(H):
    if "#" in S[i]:
#        tate.append(i+1)
        for j in range(W):
                if S[i][j] == "#" and flg >= 1:
                    sep.append([i, j-1])
                elif S[i][j] == "#":
                    flg += 1
                if j == W-1:
                        sep.append([i, j])
        flg = 0
for x in range(len(sep)):
    if sep[x][0] == sep[-1][0] and sep[x][0] < H-1:
        sep[x][0] = H-1
sep_r = sep[::-1]
ans = [([0]*W) for _ in range(H)]
num = 1

for k in sep_r:
    for i in range(k[0]+1):
        for j in range(k[1]+1):
            ans[i][j] = num
            if i == k[0] and j == k[1]:
                num += 1
                break
        else:
            continue 
        break

#print(sep_r)
for a in ans:
    print(*a)

### FIXED CODE ###

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

sep = []
flg = 0

for i in range(H):
    if "#" in S[i]:
        for j in range(W):
                if S[i][j] == "#" and flg >= 1:
                    sep.append([i, j-1])
                elif S[i][j] == "#":
                    flg += 1
                if j == W-1:
                        sep.append([i, j])
        flg = 0
for x in range(len(sep)):
    if sep[x][0] == sep[-1][0] and sep[x][0] < H-1:
        sep[x][0] = H-1
sep_r = sep[::-1]
ans = [([0]*W) for _ in range(H)]
num = 1

for k in range(len(sep)):
    if  k == 0:
        rx = 0
        ry = 0
    else:
        if sep[k-1][0] != sep[k][0]:
            rx = sep[k-1][0]+1
        if sep[k-1][1] != W-1:
            ry = sep[k-1][1]+1
        else:
            ry = 0
    for i in range(rx, sep[k][0]+1):
        for j in range(ry, sep[k][1]+1):
            ans[i][j] = num
            if i == sep[k][0] and j == sep[k][1]:
                num += 1
                break
        else:
            continue 
        break

for a in ans:
    print(*a)
### BUGGY CODE ###

# coding: utf-8
import sys,pprint

(N,M) = map(int,input().split())
paths = []
for i in range(M):
    (a,b) = map(int,input().split())
    paths.append({a,b})

print(paths, file=sys.stderr)
result = [0]*N

searchroom = []
nextsearch = []
searchroom.append(1)
while len(searchroom) > 0:
    print(searchroom,paths,file=sys.stderr)
    for n in searchroom:
        j = 0
        while j < len(paths):
            s = paths[j]
            if n in s:
                print(s,"exist", file=sys.stderr)
                print(paths,s,file=sys.stderr)
                paths.remove(s)
                j -= 1
                print(paths,s,file=sys.stderr)
                s.remove(n)
                t = s.pop()
                if result[t-1] == 0:
                    result[t-1] = n
                    nextsearch.append(t)
            j += 1
    searchroom = nextsearch.copy()
    nextsearch.clear()

print(result,file=sys.stderr)

# no判定
for i in result[1:]:
    if i == 0:
        print("No")
        sys.exit()
print("Yes")    
for i in result[1:]:
    print(i)

### FIXED CODE ###

# coding: utf-8
import sys,pprint

(N,M) = map(int,input().split())
paths = {}
for i in range(1,N+1):
    paths[i] = set()
for i in range(M):
    (a,b) = map(int,input().split())
    paths[a].add(b)
    paths[b].add(a)

result = [0]*N

searchroom = []
nextsearch = []
searchroom.append(1)
while len(searchroom) > 0:
    for n in searchroom:
        for s in paths[n]:
            if result[s-1] == 0:
                result[s-1] = n
                nextsearch.append(s)
    searchroom = nextsearch.copy()
    nextsearch.clear()

# no判定
for i in result[1:]:
    if i == 0:
        print("No")
        sys.exit()
print("Yes")    
for i in result[1:]:
    print(i)
### BUGGY CODE ###

# YouTube

def max12(x):
    if len(x) < 3:
        return x
    x.sort(reverse=True)
    return x[:2]

def f(n):
    nn = 2 ** n
    aa = list(map(int, input().split()))
    dp = [[a] for a in aa]
    # print(dp)
    for i in range(n):
        for j in range(nn - 1, -1, -1):
            if j & 1 << i == 0:
                dp[j + (1 << i)] = max12(dp[j + (1 << i)] + dp[j])
    #    print(dp)
    mx = 0
    for dk in dp[1:]:
        s = sum(dk)
        if s > mx: mx = s
        print(mx)

n = int(input())
f(n)


### FIXED CODE ###

import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

class Top2:
    def __init__(self,x=-1,y=-1):
        if x<y:x,y=y,x
        self.val=[x,y]
        self.s=x+y

    def __add__(self, other):
        i=j=0
        self.val=sorted(self.val+other.val,reverse=True)[:2]
        self.s=sum(self.val)
        return self

n=II()
aa=LI()
dp=[Top2(a) for a in aa]

for i in range(n):
    for j in range((1<<n)-1,-1,-1):
        if j>>i&1:continue
        dp[j|1<<i]+=dp[j]

mx=-1
for j in range(1,1<<n):
    mx=max(mx,int(dp[j].s))
    print(mx)
### BUGGY CODE ###

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

s = set()
for i in range(M):
  L, R = map(int, input().split())
  tmp = set()
  for j in range(L, R + 1):
    tmp |= {j}
  if i == 0:
    s |= tmp
  else:
    s &= tmp

print(len(s))

### FIXED CODE ###

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

tmpL = 0
tmpR = float("inf")
for i in range(M):
  L, R = map(int, input().split())
  tmpL = max(tmpL, L)
  tmpR = min(tmpR, R)

if tmpR - tmpL < 0:
  print(0)
else:
  print(tmpR - tmpL + 1)
### BUGGY CODE ###

N, K= map(int, input().split())
h = list(map(int, input().split()))
DP = [float('inf')]*N
DP[0] = 0
for i in range(N-1):
  for j in range(min(K,N-1-i)):
    DP[i+j+1] = min(DP[i+j+1], DP[i] + abs(h[i+j+1] - h[i]))  
print(DP[-1])

### FIXED CODE ###

N, K= map(int, input().split())
h = list(map(int, input().split()))
DP = [float('inf')]*N
DP[0] = 0
for i in range(N-1):
  L = N-1-i
  for j in range(min(K,L)):
    DP[i+j+1] = min(DP[i+j+1], DP[i] + abs(h[i+j+1] - h[i]))  
print(DP[-1])
### BUGGY CODE ###

import sys
from collections import defaultdict
input = sys.stdin.readline
mod = 998244353
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2] != 1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    return [w[0],w[1]]
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return ( m + x%m ) % m
def main():
    n,s = map(int,input().split())
    a = list(map(int, input().split()))
    dp = [[0 for _ in range(s+1)] for _ in range(n+1)]
    dp[0][0] = pow(2,n,mod)
    MODINV2 = mod_inv(2,mod)
    ans = 0
    for i in range(n):
        for j in range(s,-1,-1):
            if j-a[i] < 0:
                continue
            dp[i+1][j] += dp[i][j-a[i]]*MODINV2
            dp[i+1][j] %= mod
        for j in range(s,-1,-1):
            if j == s:
                ans += dp[i+1][j]
                ans %= mod
            else:
                dp[i+1][j] += dp[i][j]
                dp[i+1][j] %= mod
    print(ans)
if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
from collections import defaultdict
input = sys.stdin.readline
mod = 998244353
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2] != 1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    return [w[0],w[1]]
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return ( m + x%m ) % m
def main():
    n,s = map(int,input().split())
    a = list(map(int, input().split()))
    dp = [[0 for _ in range(s+1)] for _ in range(n+1)]
    dp[0][0] = pow(2,n,mod)
    MODINV2 = mod_inv(2,mod)
    ans = 0
    for i in range(n):
        for j in range(s,-1,-1):
            if j-a[i] < 0:
                continue
            dp[i+1][j] += dp[i][j-a[i]]*MODINV2
            dp[i+1][j] %= mod
        for j in range(s,-1,-1):
            if j == s:
                ans += dp[i+1][j]
                ans %= mod
            else:
                dp[i+1][j] += dp[i][j]
                dp[i+1][j] %= mod
    print(ans)
if __name__ == "__main__":
    main()
### BUGGY CODE ###

# https://atcoder.jp/contests/abc125/tasks/abc125_c

import itertools
from collections import Counter
from collections import defaultdict
import bisect

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

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

    answers = []
    for i in range(N):
        ans = 0
        for j in range(len(A)):
            if i == j:
                continue
            ans = gcd(A[j], ans)
        answers.append(ans)

    print(max(answers))


if __name__ == '__main__':
    main()


### FIXED CODE ###

# https://atcoder.jp/contests/abc125/tasks/abc125_c

import itertools
from collections import Counter
from collections import defaultdict
import bisect

memo = {}


def gcd(a, b):
    if a in memo:
        if b in memo[a]:
            return memo[a][b]
    ans = gcd_core(a, b)
    if a in memo:
        memo[a][b] = ans
    else:
        memo[a] = {}
        memo[a][b] = ans
    return ans


def gcd_core(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)


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

    ming = 0

    cand = []

    for i in range(N):
        temp = gcd(A[i], ming)
        # print(temp)
        if temp != ming:
            cand.append(i)
        ming = temp

    # print(index)

    answers = []
    for c in cand:
        ans1 = 0
        for i in range(N):
            if i != c:
                ans1 = gcd(A[i], ans1)
        answers.append(ans1)

    print(max(answers))


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

import functools
from fractions import gcd
ans = 0
n = int(input())
a = list(map(int,input().split()))
for i in range(n):
    ans = max(ans,functools.reduce(gcd,a[:i] + a[i+1:]))

print(ans)

### FIXED CODE ###

from fractions import gcd
n = int(input())
a = list(map(int,input().split()))
mae = [a[0]]
for i in range(n-1):
    mae.append(gcd(mae[i],a[i+1]))
ushiro = [a[n-1]]
for i in range(n-1):
    ushiro.append(gcd(ushiro[i],a[n-i-2]))

ans = ushiro[n-2]

for i in range(n-1):
    if i != n-2:
        ans = max(ans,gcd(mae[i],ushiro[n-i-3]))
    else:
        ans = max(ans,mae[n-2])

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

S=input()
Q=int(input())
reverseflag = 0
for _ in range(Q):
    newS = input()
    if int(newS[0]) == 1:
        reverseflag += 1
        reverseflag %= 2
    else:
        if (newS[2] == '1' and reverseflag==0) or (newS[2] != '1' and reverseflag!=0):
            S = newS[4]+S[:]
        else:
            S = S[:]+newS[4]
if reverseflag == 1:
    S = S[::-1]
print(S)

### FIXED CODE ###

from collections import deque
s = input()
s = deque(s)
q = int(input())
reverse = False
for i in range(q):
    query = input()
    if len(query) == 1:
        reverse = not reverse
    else:
        if not reverse:
            if query[2] == '1':
                s.appendleft(query[4])
            else:
                s.append(query[4])
        else:
            if query[2] == '2':
                s.appendleft(query[4])
            else:
                s.append(query[4])
s ="".join(list(s))
if reverse:
    s = s[::-1]
print(s)
### BUGGY CODE ###

N = int(input())
L = list(map(int, input().split()))
L.sort()
cnt = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        for k in range(j+1, N):
            if L[k] >= L[i]+L[j]:
                break
            else:
                cnt += 1
print(cnt)

### FIXED CODE ###

import bisect

N = int(input())
L = list(map(int, input().split()))
L.sort()

cnt = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        cnt += bisect.bisect_left(L, L[i]+L[j]) - (j+1)

print(cnt)
### BUGGY CODE ###

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

for j in range (N):
  if L[j] > 10**18:
    print(-1)
    exit()

for i in range(N):
  A *= L[i]
  
if A > 10**18:
  print("-1")
else:
  print(A)

### FIXED CODE ###

N = int(input())
L = list(map(int, input().split()))
A = []
ans = 1
L.sort()

for i in range (N):
  ans*= L[i]
  if ans == 0 or ans > 10**18:
    break
if ans > 10**18:
  print(-1)
else:
  print(ans)