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

from operator import mul
from functools import reduce
import itertools

N = int(input())

# N = i*jをみつける
# (i, j)


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

prime_list = prime_factorize(N)


#print(prime_list)


import copy
if len(prime_list)<=1:
    result = N-1
else:
    result = 10**12

for i in range(len(prime_list)//2):
    # i個抽出
    tmp = list(itertools.combinations(prime_list, i+1))
    tm = list(map(list, tmp))
    for _ in tm:
        temp_origin_list = copy.copy(prime_list)
        for item in _:
            temp_origin_list.remove(item)
        #print(_, temp_origin_list)
        result = min(result, reduce(mul, _) + reduce(mul, temp_origin_list) - 2)
print(result)

### FIXED CODE ###

import math
N = int(input())
result = N
for i in range(1, int(math.sqrt(N))+2):
    if N % i == 0:
        result = min(result, i - 1 + N//i - 1)
print(result)
### BUGGY CODE ###

s = list(str(input()))
ans = 0
drop = False
l = 0
while l <= len(s) - 2:
    if drop == False:
        if s[l] != s[l + 1]:
            ans += 2
            del s[l:l + 2]
            drop = True
        else:
            l += 1
    while drop == True and len(s) >= 2:
        if 0 <= l:
            l -= 1
        if s[l] != s[l + 1]:
            ans += 2
            del s[l:l + 2]
        else:
            drop = False
            l += 1
print(ans)

### FIXED CODE ###

s = str(input())
c0 = s.count('0')
c1 = s.count('1')
print(2 * min(c0, c1))
### BUGGY CODE ###

n = int(input())
h = list(map(int, input().split()))
cnt = [0]*n
for i in range(n):
  for j in range(n):
    if i+1 == h[j]:
      cnt[i] += j+1
      
print(*cnt)

### FIXED CODE ###

n = int(input())
h = tuple(map(int, input().split()))
ans = [0]*n
for i in range(n):
  ans[h[i]-1] = i+1
print(*ans)
### BUGGY CODE ###

import itertools

n = int(input())
a_l = map(int, input().split())


ans = 0
for v1, v2 in itertools.combinations(a_l, 2):
    ans += v1 * v2
    ans = ans % (10 ** 9 + 7)
    
print(ans)

### FIXED CODE ###

n = int(input())
a_list = input().split()

a_list_reverse = a_list[::-1]
# print(a_list_reverse)

rusekiwa = [0] * (len(a_list_reverse) - 1)
sum_v = 0
for i in range(len(a_list_reverse) - 1):
    sum_v += int(a_list_reverse[i])
    rusekiwa[i] = sum_v
# print(rusekiwa)

ans = 0
for i in range(len(a_list) - 1):
    v = int(a_list[i]) * rusekiwa[-1 - (i)]
    # print(v)
    # v = v % (10 ** 9 + 7)
    ans += v
    ans = ans % (10 ** 9 + 7)

# ans = ans % (10 ** 9 + 7)
print(ans)
### BUGGY CODE ###

h,w,d = map(int,input().split())
l = [list(map(int,input().split())) for i in range(h)]
ans = [[0]*(h*w+1) for i in range(d)]
px = [0]*(h*w+1)
py = [0]*(h*w+1)
for i in range(h):
    for j in range(w):
        px[l[i][j]],py[l[i][j]] = i,j  

count =[0]*(h*w+1)
for i in range(d+1,h*w+1):
    count[i] = count[i-d]+abs(px[i]-px[i-d])+abs(py[i]-py[i-d])

n = int(input())
for i in range(n):
    a,b = map(int,input().split())
    print(count[b]-count[a])

### FIXED CODE ###

h,w,d = map(int,input().split())
px = [0]*(h*w+1)
py = [0]*(h*w+1)
for i in range(h):
    l = list(map(int,input().split()))
    for j in range(w):
        px[l[j]],py[l[j]] = i,j  

count =[0]*(h*w+1)
for i in range(d+1,h*w+1):
    count[i] = count[i-d]+abs(px[i]-px[i-d])+abs(py[i]-py[i-d])

n = int(input())
for i in range(n):
    a,b = map(int,input().split())
    print(count[b]-count[a])
### BUGGY CODE ###

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    K = I()

    # メソッドのみ版
    def search(s):
        d = collections.defaultdict(lambda: inf)
        q = [(1,s)]
        qi = 0
        v = collections.defaultdict(bool)
        v[s] = True
        while len(q):
            k, u = q[0]
            q = q[1:]
            if u == 0:
                return k
            t = u*10 % K
            while not v[t]:
                q.append((k, t))
                v[t] = True
                t = t*10 % K

            i = 1
            t = (u+i) % K
            while not v[t]:
                q.append((k+1, t))
                v[t] = True
                i = i*10 % K
                t = u+i % K

    return search(1)

print(main())




### FIXED CODE ###

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    K = I()

    # メソッドのみ版
    def search(s):
        d = collections.defaultdict(lambda: inf)
        q = [(1,s)]
        d[s] = 1
        qi = 0
        v = [False] * (K+1)
        v[s] = True
        while len(q):
            k, u = heapq.heappop(q)
            if u == 0:
                return k
            t = u*10 % K
            v[u] = True
            while not v[t]:
                if t == 0:
                    return k
                if d[t] > k:
                    heapq.heappush(q, (k, t))
                    d[t] = k
                v[t] = True
                t = t*10 % K

            i = 1
            t = (u+i) % K
            while not v[t] and t != u:
                if d[t] > k+1:
                    heapq.heappush(q, (k+1, t))
                    d[t] = k+1
                    i = i*10 % K
                    t = (u+i) % K
                else:
                    break

    return search(1)

print(main())
### BUGGY CODE ###

#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
  read_all = [tuple(map(int, input().split())) for _ in range(N)]
  return map(list,zip(*read_all))

#################

from scipy import sparse

import numpy as np
S = str(input())
N = len(S)
A = np.matrix([[0]*N for _ in range(N)])
for i in range(N):
  if S[i]=='R':
    A[i,i+1] = 1
  else:
    A[i,i-1] = 1


x = np.array([1]*N) * sparse.lil_matrix(np.linalg.matrix_power(A,10**100))
print(*x)

### FIXED CODE ###

#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
  read_all = [tuple(map(int, input().split())) for _ in range(N)]
  return map(list,zip(*read_all))

#################

S = str(input())
n = len(S)
ans = [0]*n

left = 0
while left<=n-1:
  R_pos = n-1
  for i in range(left,n):
    if S[i]=='L':
      R_pos = i-1
      L_pos = i
      break
  if R_pos == n-1:
    ans[R_pos] += R_pos-left + 1
    break
  right = n-1
  for j in range(i+1,n):
    if S[j] == 'R':
      right = j-1
      break
  ans[R_pos] += (R_pos-left)//2 + (right-R_pos)//2 + 1
  ans[L_pos] += (L_pos-left)//2 + (right-L_pos)//2 + 1
  if right == n-1:
    break
  left = j

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

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

for i in range(1,n+1):
    tmp = a[:i-1]+a[i:]
    # print(tmp)
    print(max(tmp))


### FIXED CODE ###

n = int(input())
first=(0,0)
second=0
for i in range(n):
    num = int(input())
    if num>= first[0]:
        second = first[0]
        first=(num,i)
    elif num>=second:
        second = num
# print(n)
for i in range(n):
    if i==first[1]:
        print(second)
    else:
        print(first[0])
### BUGGY CODE ###

k, s = list(map(int, input().split()))
ct = 0
for x in range(k+1):
    for y in range(min(k+1, s-x+1)):
        for z in range(min(k+1,s-x-y+1)):
            if x + y + z == s:
                ct += 1
                break;
print(ct)

### FIXED CODE ###

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

import sys
sys.setrecursionlimit(10**6)

N, Q = map(int,input().split())
ad = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int,input().split())
    a -= 1
    b -= 1
    ad[a].append(b)
    ad[b].append(a)

cnt = [0] * N

for _ in range(Q):
    p, x = map(int,input().split())
    p -= 1
    cnt[p] += x

ans_list = [0] * N

def dfs(v=0, pv=-1, res=0):
    res += cnt[v]
    ans_list[v] = res
    for nv in ad[v]:
        if nv == pv:
            continue
        dfs(nv, v, res)

dfs()

print(*ans_list)

### FIXED CODE ###

from collections import deque

N, Q = map(int,input().split())
ad = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int,input().split())
    a -= 1
    b -= 1
    ad[a].append(b)
    ad[b].append(a)

cnt = [0] * N

for _ in range(Q):
    p, x = map(int,input().split())
    p -= 1
    cnt[p] += x

ans_list = [0] * N

dq = deque()
dq.append((0,-1,0))

while dq:
    v, pv, res = dq.popleft()
    res += cnt[v]
    ans_list[v] = res
    for nv in ad[v]:
        if nv == pv:
            continue
        dq.append((nv, v, res))

print(*ans_list)
### BUGGY CODE ###

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

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

bit_list = [0 for i in range(50)]
K_bit_list = [0 for i in range(50)]
for i in range(N):
    a = A[i]
    for j in range(50):
        if a%2==1:
            bit_list[j]+=1
        a=a//2
        if a==0:
            break


max_score=0
for i in range(K+1):
    bit=bin(i)[2:]
    bit=bit[::-1]
    score=0
    for j in range(50):
        if j<len(bit):
            if bit[j]=="0":
                score+=bit_list[j]*(2**j)
            else:
                score+=(N-bit_list[j])*(2**j)
        else:
            score+=bit_list[j]*(2**j)
            
    max_score=max(score,max_score)
    
print(max_score)

### FIXED CODE ###

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

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

bit_list = [0 for i in range(50)]
for i in range(N):
    a = A[i]
    for j in range(50):
        if a%2==1:
            bit_list[j]+=1
        a=a//2
        if a==0:
            break

bitk=bin(K)[2:]
lenk = len(bitk)
bitk=bitk[::-1]

maxscore=0
for i in range(len(bitk)):
    patA=0
    if bitk[i]=="1":
        first=i
        for j in range(50):
            if j<first:
                patA+=max(N-bit_list[j],bit_list[j])*(2**j)
            elif j==first:
                patA+=bit_list[j]*(2**j)
            elif j<lenk:
                if bitk[j]=="0":
                    patA+=bit_list[j]*(2**j)
                else:
                    patA+=(N-bit_list[j])*(2**j)
            else:
                patA+=bit_list[j]*(2**j)


    maxscore=max(patA,maxscore)

patB=0
for i in range(50):
    patB+=bit_list[i]*(2**i)
patC=0
for i in range(50):
    if i<lenk:
        if bitk[i]=="0":
            patC+=bit_list[i]*(2**i)
        else:
            patC+=(N-bit_list[i])*(2**i)
    else:
        patC+=bit_list[i]*(2**i)

print(max(maxscore,patB,patC))
### BUGGY CODE ###

N = int(input())
S = input()
import itertools

tmp=0
C = itertools.combinations(S, 3)
for c in C:
    if set(c)==set('RGB'):
        tmp+=1
for j in range(1, N//2+1):
    for i in range(N):
        if (i+(j*2))>=N:
            break
        if set((S[i], S[i+j], S[i+(j*2)])) == set('RGB'):
#             print(i, i+j, i+(j*2))
            tmp-=1
print(tmp)

### FIXED CODE ###

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

R = S.count('R')
G = S.count('G')
B = S.count('B')
tmp = 0
for i in range(N):
    for j in range(i+1, N):
        k = j + (j - i)
        if k >= N:
            break
        if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:
            tmp-=1
print(tmp + R*G*B)
### BUGGY CODE ###

N,K = map(int,input().split())
p = list(map(int,input().split()))
E = []
for i in range(0,len(p)):
    E.append((p[i]+1)/2)
def maxexp(p,E,K):
    s = 0
    for i in range(0,len(p)-K+1):
        t = 0
        for j in range(0,K):
            t = t + E[i+j]
        s = max(s,t)
    return s
print(maxexp(p,E,K))

### FIXED CODE ###

N,K = map(int,input().split())
p = list(map(int,input().split()))
def maxexp(p,K):
    s = 0 
    for i in range(0,K):
        s = s + p[i]
        t = s
    for j in range(0,len(p)-K):
        s = s - p[j] + p[j+K]
        t = max(s,t)
    return (t+K)/2
print(maxexp(p,K))
### BUGGY CODE ###

X = str(input())
lx = len(X)
st = []

for i in range(lx):
  if X[i] == "S":
    st.append("S")
  else:
    if "S" in st:
      st.pop()
    else:
      st = ["T"] + st
   
print(len(st))

### FIXED CODE ###

X = str(input())
X = X.replace("ST","")
lx = len(X)
s_count = 0
t_count = 0
for i in range(lx):
  if X[i] == "S":
    s_count += 1
  else:
    if s_count:
      s_count -= 1
    else:
      t_count += 1
   
print(s_count + t_count)
### BUGGY CODE ###

import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from collections import defaultdict
from bisect import bisect_right

s = ns()
t = ns()

ok = True

sset = set(list(s))
for ti in t:
    if ti not in sset:
        ok = False
        break

if not ok:
    print(-1)

else:
    n = len(s)

    sdouble = s + s

    charidx = defaultdict(list)

    for i, si in enumerate(s):
        charidx[si].append(i)
    for i, si in enumerate(s):
        charidx[si].append(n+i)

    move = [{ki: -1 for ki in charidx.keys()} for _ in range(n)]

    for i, si in enumerate(s):
        for ki in charidx.keys():
            nexidx = bisect_right(charidx[ki], i)
            move[i][ki] = (charidx[ki][nexidx] - i) % (n+1)


    ans = s.index(t[:1])
    cur = ans

    for i, ti in enumerate(t[1:]):
        nex = move[cur][ti]
        ans += nex
        cur = (cur + nex) % n

    print(ans+1)


### FIXED CODE ###

import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from collections import defaultdict
from bisect import bisect_right

s = ns()
t = ns()

ok = True

sset = set(list(s))
for ti in t:
    if ti not in sset:
        ok = False
        break

if not ok:
    print(-1)

else:
    n = len(s)

    charidx = defaultdict(list)

    for i, si in enumerate(s):
        charidx[si].append(i)
    for i, si in enumerate(s):
        charidx[si].append(n+i)

    ks = charidx.keys()

    move = [{ki: -1 for ki in ks} for _ in range(n)]

    for i, si in enumerate(s):
        for ki in ks:
            idxlist = charidx[ki]
            nexidx = bisect_right(idxlist, i)
            move[i][ki] = (idxlist[nexidx] - i) % (n+1)

    cur = s.index(t[:1])
    ans = cur
    for ti in t[1:]:
        nex = move[cur][ti]
        ans += nex
        cur = (cur + nex) % n

    print(ans+1)
### BUGGY CODE ###

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

ans = -10**15
for i in range(n+1):
    b1 = a[:n+i]
    b2 = a[n+i:]

    b1.sort(reverse=True)
    s1 = sum(b1[:n])
    b2.sort()
    s2 = sum(b2[:n])
    ans = max(ans, s1-s2)

print(ans)

### FIXED CODE ###

import heapq

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

ans = -10**15
h1 = a[:n]
h2 = [-a[i] for i in range(2*n, 3*n)]
heapq.heapify(h1)
heapq.heapify(h2)

h1sum = sum(a[:n])
h2sum = sum(a[2*n:])

box1 = [h1sum]
box2 = [h2sum]

for i in range(1, n+1):
    heapq.heappush(h1, a[n+i-1])
    h1sum += a[n+i-1] - heapq.heappop(h1)
    box1.append(h1sum)

for i in range(1, n+1):
    heapq.heappush(h2, -a[2*n-i])
    h2sum += a[2*n-i] - (-heapq.heappop(h2))
    box2.append(h2sum)

for i in range(n+1):
    ans = max(ans, box1[i] - box2[n-i])

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

N = int(input())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7
ans = 0
for i in range(60):
    cnt = 0
    for a in A:
        if a >> i & 1:
            cnt += 1
    ans += cnt * (N - cnt) * pow(2, i)
    ans %= mod
print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7


def mod_pow(a, p):
    if p == 0:
        return 1
    if p % 2 == 0:
        half_p = p // 2
        half = mod_pow(a, half_p)
        return half * half % mod
    else:
        return a * mod_pow(a, p - 1) % mod


ans = 0
for i in range(60):
    cnt = 0
    for a in A:
        if a >> i & 1:
            cnt += 1
    now = cnt * (N - cnt) % mod
    ans += now * mod_pow(2, i) % mod
    ans %= mod
print(ans)
### BUGGY CODE ###

num = [True]*(100001)
num[0] = num[1] = False
for i in range(2,317):
  if num[i]:
    for j in range(i**2, 100000, i):
      num[j] = False

for i in range(int(input())):
  _input = input().split(' ')
  sum = 0
  for i in range(int(_input[0]), int(_input[1])+1):
    if (num[i]) and (num[int((i+1)/2)]):
      sum = sum + 1
  print(sum)

### FIXED CODE ###

num = [True]*100001
num[0] = num[1] = False
for i in range(2,317):
  if num[i]:
    for j in range(i**2, 100000, i):
      num[j] = False

c = [0]*100002
for i in range(3, 100001, 2):
  if (num[i]) and (num[int((i+1)/2)]):
    c[i] = c[i] + 1

for i in range(3, 100001):
  c[i] = c[i] + c[i-1]

for i in range(int(input())):
  _input = input().split(' ')
  print(c[int(_input[1])] - c[int(_input[0])-1])
### BUGGY CODE ###

n = int(input())
ar = [[] for i in range(n)]
for i in range(n-1):
    ipt = list(map(int,input().split()))
    ar[ipt[0]-1].append([ipt[1]-1,ipt[2]%2])
    ar[ipt[1]-1].append([ipt[0]-1,ipt[2]%2])

ans = [[] for i in range(n)]
u = 0
ans[u] = 0
queue = [u] #キュー
check = [u] #訪問済み

while True:
    if len(queue) == 0:
        break
    u = queue[0]
    queue.pop(0)
    for v in ar[u]:
        if not v[0] in check:
            check.append(v[0])
            ans[v[0]] = (ans[u] + v[1])%2
            queue.append(v[0])

for i in range(len(ans)):
    print(ans[i])

### FIXED CODE ###

n = int(input())
ar = [[] for i in range(n)]
for i in range(n-1):
    ipt = list(map(int,input().split()))
    ar[ipt[0]-1].append((ipt[1]-1,ipt[2]))
    ar[ipt[1]-1].append((ipt[0]-1,ipt[2]))

ans = [-1 for i in range(n)]
u = 0
ans[u] = 0
queue = [u] #キュー
l = 1
while True:
    if l == 0:
        break
    u = queue.pop(0)
    l -= 1
    for v in ar[u]:
        if ans[v[0]] < 0:
            ans[v[0]] = ans[u] + v[1]
            queue.append(v[0])
            l+=1

for i in range(n):
    print(ans[i]%2)
### BUGGY CODE ###

def main():
    S = list(input())
    N = len(S)
    t = 0
    A = [0] * 2019
    A[0] += 1
    for i in range(N):
        t = (t + int(S.pop()) * 10 ** i) % 2019
        A[t] += 1
    result = sum([a*(a-1)//2 for a in A])
    print(result)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    S = list(input())
    N = len(S)
    t = 0
    A = [0] * 2019
    A[0] += 1
    d = 1
    for s in reversed(S):
        d *= 10
        d %= 2019
        t += (int(s) * d)
        t %= 2019
        A[t] += 1
    result = sum([a*(a-1)//2 for a in A])
    print(result)


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

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

INF = float('inf')
dp = [INF] * (N)
dp[0] = 0

for i in range(1,N):
    cost = INF
    for j in range(max(0,i-K),i):
        # print(h[j],':',h[i])
        dp[i] = min(dp[i], dp[j]+abs(h[j]-h[i]))
    # print(dp)
print(dp[-1])

### FIXED CODE ###

import numpy as np

N,K = map(int, input().split())
h = np.array(list(map(int, input().split())))
dp = np.full(N,10**10)
dp[0] = 0
for i in range(1,N):
    start = max(0,i-K)
    dp[i] = np.min(dp[start:i]+np.abs(h[i]-h[start:i]))
print(int(dp[-1]))
### BUGGY CODE ###

#cited from maspy
import itertools
import numpy as np

N, M, Q = map(int, input().split())
abcd = [list(map(int, input().split())) for i in range(Q)]
A = np.array(list(itertools.combinations_with_replacement(range(1, M + 1), N)))
n = len(A)
score = [0]*n
ans = 0
for j in range(n):
  for i in range(Q):
    a = abcd[i][0]
    b = abcd[i][1]
    c = abcd[i][2]
    d = abcd[i][3]
    if A[j][b-1] - A[j][a-1] == c:
      score[j] += d
  ans = max(ans,score[j])
print(ans)

### FIXED CODE ###

import itertools
import numpy
N, M, Q = map(int,input().split())
abcd = []*Q
d_list = []
sum_d = 0
for _ in range(Q):
  abcd.append(list(map(int,input().split())))

A = [1 for i in range(N)]
for A in itertools.combinations_with_replacement(range(1, M+1), N):
  for i in range(Q):
    if A[abcd[i][1]-1]-A[abcd[i][0]-1] == abcd[i][2]:
      d_list.append(abcd[i][3])
  if sum_d <= sum(d_list):
    sum_d = sum(d_list)
  d_list.clear()
print(sum_d)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
x,y,z,k = map(int, input().split())

a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

v = []


d = [e1+e2 for e1 in a for e2 in b]
d.sort(reverse=True)
d = d[:k]

e = [e1+e2 for e1 in d for e2 in c]
e.sort(reverse=True)


for i in range(k):
    print(e[i])



### FIXED CODE ###

# -*- coding: utf-8 -*-
x,y,z,k = map(int, input().split())

a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)


d = [e1+e2 for e1 in a for e2 in b]
d.sort(reverse=True)
d = d[:k]

e = [e1+e2 for e1 in d for e2 in c]
e.sort(reverse=True)


for i in range(k):
    print(e[i])
### BUGGY CODE ###

N = int(input())
A = [el for el in map(int,input().split())]
res = 1
for el in A:
  res *= el
if res <= 10**18:
  print(res)
else:
  print(-1)
  

### FIXED CODE ###

import sys
N = int(input())
A = [el for el in map(int,input().split())]
if 0 in A : 
    print(0)
    sys.exit(0)
res = 1
for el in A:
  res *= el
  if res - 10**18 > 0:
    print(-1)
    sys.exit(0)
print(res)