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

import bisect


N, Q = map(int, input().split(" "))
check_points = [list(map(int, input().split(" "))) for _ in range(N)]
querys = [int(input()) for _ in range(Q)]
time = {}
for q in querys:
    time[q] = -1

for s, f, x in check_points:
    start = s-x
    end = f-x
    left = bisect.bisect_left(querys, start)
    for q in querys[left:]:
        if q >= end:
            break
        if time[q] == -1 or time[q] > x:
            time[q] = x

for q in querys:
    print(time[q])


### FIXED CODE ###

from bisect import bisect_left
from operator import itemgetter

N, Q = map(int, input().split(" "))
check_points = [tuple(map(int, input().split(" "))) for _ in range(N)]
querys = [int(input()) for _ in range(Q)]
time = [-1 for _ in range(Q)]
jump = [-1 for _ in range(Q)]
check_points = sorted(check_points, key=itemgetter(2))
b_left = bisect_left

for line in check_points:
    s, f, x = line
    start = s-x
    end = f-x
    left = b_left(querys, start)
    right = b_left(querys, end)
    while left < right:
        if time[left] == -1:
            time[left] = x
            jump[left] = right
            left += 1
        else:
            left = jump[left]

for t in time:
    print(t)
### BUGGY CODE ###

uL = []
oL = []
c = 0

things = int(input())
for i in range(things):
    p = input()
    uL.append(p)
    
x = [oL.append(x) for x in uL if x not in oL]

print(len(x))

### FIXED CODE ###

s = set([])
things = int(input())

for i in range(things):
    p = input()
    s.add(p)

print(len(s))
### BUGGY CODE ###

N, K = map(int, input().split())
LRs = [tuple(map(int, input().split())) for _ in range(K)]
mod = 998244353
    
mem = [0] * (N)
mem[N-1] = 1

for _i in range(N-1):
    i = N-2 - _i
    for l, r in LRs:
        if i+l < N:
            mem[i] += sum(mem[i+l:min(i+r+1, N)])

    mem[i] %= mod

print(mem[0])

### FIXED CODE ###

N, K = map(int, input().split())
LRs = [tuple(map(int, input().split())) for _ in range(K)]
mod = 998244353

def diff(l):
    tmp = None
    res = []
    for elm in l:
        if tmp is None:
            res.append(elm)
            tmp = elm
        else:
            res.append(elm-tmp)
            tmp = elm

    return res

res_diff = [0] * N
res_diff[1] = -1
res = [1]

for i in range(N-1):
    for l, r in LRs:
        if i+l < N:
            res_diff[i+l] += res[i]
        if i+r+1 < N:
            res_diff[i+r+1] -= res[i]
    
    res_next = (res[-1]+res_diff[i+1])%mod
    res.append(res_next)

print(res[N-1])
### BUGGY CODE ###

import math
k = int(input())
a = 0
for m in range(1,k+1):
    for n in range(1,k+1):
        for l in range(1,k+1):
             b = math.gcd(m,n)
             #print("b={}".format(b))
             a = a + math.gcd(b,l)
             #print("a={}".format(a))
print(a)


### FIXED CODE ###

import math
k = int(input())
a = 0
for m in range(1,k+1):
    for n in range(1,k+1):
        b = math.gcd(m,n)
        for l in range(1,k+1):
            a += math.gcd(l,b)
print(a)
### BUGGY CODE ###

N = int(input())
S = [input() for _ in range(N)]
SS = sorted(list(set(S)))
count = []
for i in SS:
    count.append(S.count(i))
ans = max(count)
for j in range(len(SS)):
    if count[j] == ans:
        print(SS[j])

### FIXED CODE ###

count = {}
for i in range(int(input())):
    S = input()
    if S in count:
        count[S] += 1
    else:
        count[S] = 1
ans = max(count.values())
print(*sorted([A[0] for A in count.items() if A[1] == ans]))
### BUGGY CODE ###

import math
A,B=map(int,input().split())
def cf(a,b):
  cf=[]
  for i in range(1,min(a,b)+1):
    if a%i==0 and b%i==0:
      cf.append(i)
  return cf
x=[x for x in cf(A,B) if all(x % y != 0 for y in range(2, x))]
print(len(x))

### FIXED CODE ###

from fractions import gcd
A,B=map(int,input().split())
s=set()
x=gcd(A,B)
y=2
while y*y<=x:
  while x%y==0:
    s.add(y)
    x//=y
  y+=1
if x>1:
  s.add(x)
print(len(s)+1)
### BUGGY CODE ###

# numChar種類で条件を満たせるかを判定する
def check(As, numChar):
    Ss = [(-1, -1)]
    APrev = As[0]
    for A in As[1:]:
        if APrev >= A: # 文字列長が同じor短くなる場合
            if numChar == 1: return False
            # A文字目より後ろを削除する
            while Ss[-1][0] > A:
                Ss.pop()
            # A文字目を[+1]する
            posS = A
            while Ss[-1] == (posS, numChar - 1):
                Ss.pop()
                posS -= 1
            if posS == 0:
                return False
            elif Ss[-1][0] == posS:
                Ss[-1] = (posS, Ss[-1][1] + 1)
            else:
                Ss.append((posS, 1))
        APrev = A
    return True

# 条件を満たす最小のnumCharを二分探索する
def solve(As, N):
    lft, rgt = 0, N
    while rgt - lft > 1:
        mid = (lft + rgt) // 2
        isOK = check(As, mid)
        if isOK:
            rgt = mid
        else:
            lft = mid
    return rgt

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

print(solve(As, N))


### FIXED CODE ###

# numChar種類で条件を満たせるかを判定する
def check(As, numChar):
    Ss = [(-1, -1)]
    APrev = As[0]
    for A in As[1:]:
        if APrev >= A: # 文字列長が同じor短くなる場合
            if numChar == 1: return False
            # A文字目より後ろを削除する
            while Ss[-1][0] > A:
                Ss.pop()
            # A文字目を[+1]する
            posS = A
            while Ss[-1] == (posS, numChar - 1):
                Ss.pop()
                posS -= 1
            if posS == 0:
                return False
            elif Ss[-1][0] == posS:
                Ss[-1] = (posS, Ss[-1][1] + 1)
            else:
                Ss.append((posS, 1))
        APrev = A
    return True

# 条件を満たす最小のnumCharを二分探索する
def solve(As, N):
    lft, rgt = 0, N
    while rgt - lft > 1:
        mid = (lft + rgt) // 2
        isOK = check(As, mid)
        if isOK:
            rgt = mid
        else:
            lft = mid
    return rgt

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

print(solve(As, N))
### BUGGY CODE ###

import heapq

nm = list(map(lambda x: int(x), input().split()))
n = nm[0]
m = nm[1]

a = list(map(lambda x: int(x), input().split()))
bc = [list(map(lambda x: int(x), input().split())) for i in range(m)]

head_a = []

for a_item in a:
  heapq.heappush(head_a, a_item)

# そーと
bc.sort(key=lambda x: x[1])
bc = list(reversed(bc))

for bc_item in bc:
  for i in range(bc_item[0]):
    head_a_item = heapq.heappop(head_a)
    heapq.heappush(head_a, max(head_a_item, bc_item[1]))

print(sum(head_a))

### FIXED CODE ###

import heapq

nm = list(map(lambda x: int(x), input().split()))
n = nm[0]
m = nm[1]

a = list(map(lambda x: int(x), input().split()))
bc = [list(map(lambda x: int(x), input().split())) for i in range(m)]

head_a = []

for a_item in a:
  heapq.heappush(head_a, a_item)

# そーと
bc.sort(key=lambda x: x[1])
bc = list(reversed(bc))

for bc_item in bc:
  done = False
  for i in range(bc_item[0]):
    head_a_item = heapq.heappop(head_a)
    if (head_a_item >= bc_item[1]):
      heapq.heappush(head_a, max(head_a_item, bc_item[1]))
      done = True
      break
    else:
      heapq.heappush(head_a, max(head_a_item, bc_item[1]))
  if (done):
    break

print(sum(head_a))
### BUGGY CODE ###

n = int(input())
a = [int(i) for i in input().split()]
b = []
is_even = len(a) % 2 == 0

if is_even:
    for i in range(n):
        if i % 2 == 0:
            b.append(a[i])
        else:
            b.insert(0, a[i])
else:
    for i in range(n):
        if i % 2 == 0:
            b.insert(0, a[i])
        else:
            b.append(a[i])
print(" ".join(map(str, b)))


### FIXED CODE ###

n = int(input())
a = [int(i) for i in input().split()]
if n % 2 == 0:
    b = a[1::2][::-1] + a[::2]
    print(*b)
else:
    b = a[::2][::-1] + a[1::2]
    print(*b)
### BUGGY CODE ###

N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
for i in range(M):
    A[-1]=A[-1]//2
    A.sort()
print(sum(A))

### FIXED CODE ###

import heapq 

N,M=map(int,input().split())
A=[-a for a in list(map(int,input().split()))]
heapq.heapify(A)
for _ in [0]*M:
    a=heapq.heappop(A)
    heapq.heappush(A,-((-a)//2))
    
res=0
for i in range(N):
    a=heapq.heappop(A)
    res+=-a
print(res)
### BUGGY CODE ###


import numpy as np

from scipy.sparse.csgraph import connected_components

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

cities = [[0] * N for i in range(N)]
# print(cities)

cities = np.array(cities)

for i in range(M):
    i1, i2 = map(int, input().split())
    cities[i1-1][i2-1] = 1
    cities[i2-1][i1-1] = 1
#     print(cities)
    
# print(cities)

n, labels = connected_components(cities)
print(n-1)

### FIXED CODE ###


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

# cities = [[0] * N for i in range(N)]
# print(cities)
cities = {}
 
for a in range(N):
    cities[a+1] = []
# print(cities)
 
for i in range(M):
    i1, i2 = map(int, input().split())
    cities[i1].append(i2)
    cities[i2].append(i1)
# print(cities)
def connected_components(graph):
    seen = set()
    def component(n):
        nodes = set([n])
        while nodes:
            n = nodes.pop()
            seen.add(n)
            nodes |= set(graph[n]) - seen
            yield n
    for n in graph:
        if n not in seen:
            yield component(n)
print(len([list(x) for x in connected_components(cities)])-1)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(1000000)

from functools import reduce
def gcd_list(n):
    return reduce(gcd, n)

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

n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n):
    ans = max(ans, gcd_list(a[:i] + a[i + 1:]))
print(ans)


### FIXED CODE ###

import fractions

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

l = [a[0]]
for i in range(n - 1):
    l.append(fractions.gcd(l[i], a[i + 1]))

r = [a[-1]]
for i in range(2, n + 1):
    r.append(fractions.gcd(r[i - 2], a[-i]))
r.reverse()

ans = r[1]
for i in range(n - 2):
    ans = max(ans, fractions.gcd(l[i], r[i + 2]))
ans = max(ans, l[-2])
print(ans)
### BUGGY CODE ###

class BIT:
    def __init__(self, a, func=int.__add__, one=0):
        self.n = len(a)
        self.func = func
        self.one = one
        self.a = [0] * (self.n + 1)

        for i, j in enumerate(a):
            self.update(i, j)

    def update(self, i, x):
        i += 10
        while i <= self.n:
            self.a[i] = self.func(self.a[i], x)
            i += i & (-i)

    def get(self, i):
        i += 10
        s = self.one
        while i != 0:
            s = self.func(s, self.a[i])
            i -= i & (-i)
        return s


n, q = map(int, input().split())
c = [int(i)-1 for i in input().split()]
que = [[i, [int(i)-1 for i in input().split()], 0] for i in range(q)]
que.sort(key=lambda x: x[1][1])
last = [-1] * n
bit = BIT([0]*(n+100))
j = 0
for i in range(n):
    if last[c[i]] != -1:
        bit.update(last[c[i]], -1)
    bit.update(i, 1)
    last[c[i]] = i
    while j < q and que[j][1][1] == i:
        que[j][2] = bit.get(i) - bit.get(que[j][1][0]-1)
        j += 1
que.sort()
for i in que:
    print(i[-1])


### FIXED CODE ###

import sys
input = sys.stdin.readline


class BIT:
    def __init__(self, a):
        self.n = len(a)
        self.a = [0] * (self.n + 1)

        for i, j in enumerate(a):
            self.update(i, j)

    def update(self, i, x):
        i += 1
        while i <= self.n:
            self.a[i] = self.a[i] + x
            i += i & (-i)

    def get(self, i):
        s = 0
        i += 1
        while i != 0:
            s = s + self.a[i]
            i -= i & (-i)
        return s


def inmin(x):
    return int(x)-1


if __name__ == "__main__":
    n, q = map(int, input().split())
    c = list(map(inmin, input().split()))
    que = [[i, list(map(inmin, input().split()))] for i in range(q)]
    que.sort(key=lambda x: x[1][1])
    ans = [0] * q

    last = [-1] * n
    bit = BIT([0]*(n+10))
    j = 0
    for i in range(n):
        if last[c[i]] >= 0:
            bit.update(last[c[i]]+5, -1)
        bit.update(i+5, 1)
        last[c[i]] = i
        while j < q and que[j][1][1] == i:
            ans[que[j][0]] = bit.get(i+5) - bit.get(que[j][1][0]+4)
            j += 1
    print(*ans)
### BUGGY CODE ###

A, B, K = list(map(int,input().split(' ')))
x = [i for i in range(A,B+1)]
leng = len(x)
s_f = x[:K]
s_b = x[leng-K:]
ans = s_f + s_b
ans =list(set(ans))
ans.sort()

for i in ans:
  print(i)

### FIXED CODE ###

A, B, K = list(map(int,input().split(' ')))
'''
x = [i for i in range(A,B+1)]
s_f,s_b = x[:K],x[len(x)-K:]
ans = s_f + s_b
ans =list(set(ans))
#ans.sort()
if len(range(A,B+1))<K:
  [print(i) for i in range(A,B+1)]
else:
  x = [i for i in range(A,B+1)]
  s_f,s_b = x[:K],x[len(x)-K:]
  ans = s_f + s_b
  ans =list(set(ans))
  ans.sort()
  [print(i) for i in ans]

'''
if (B-A+1)<K:
  s =  list(range(A,B+1))
  [print(i) for i in s]
else:           
  s_f = list(range(A,A+K))
  s_b = list(range(B,B-K,-1))
  ans = s_f + s_b
  ans =list(set(ans))
  ans.sort()
  [print(i) for i in ans]
### BUGGY CODE ###

N,Y=map(int,input().split())
x=-1
y=-1
z=-1
for i in range(N+1):
    for j in range(N+1):
        for k in range(N+1):
            if  i*10000+j*5000+k*1000==Y and i+j+k==N:
                x=i
                y=j
                z=k
           

print(x,y,z)

### FIXED CODE ###

N,Y=map(int,input().split())
x=-1
y=-1
z=-1
for i in range(N+1):
    for j in range(N-i+1):   
         if  i*10000+j*5000+(N-i-j)*1000==Y:
                x=i
                y=j
                z=N-i-j
           

print(x,y,z)
### BUGGY CODE ###

S = list(raw_input())

if len(set(S)) == 1:
    print 0
else:
    count = 0
    while len(set(S)) > 1:
        if S[-1] == 'W':
            added = 'B'
        else:
            added = 'W'
        S += added
        count += 1

        i = -2
        while S[i] != added:
            if S[i] == 'W':
                S[i] = 'B'
            else:
                S[i] = 'W'
            i -= 1
        # break
    print count


### FIXED CODE ###

S = list(raw_input())

if len(set(S)) == 1:
    print 0
else:
    while S[-1] == S[-2]:
        del S[-1]
    del S[-1]

    count = 1
    for i in xrange(len(S)-1):
        if S[i] != S[i+1]:
            count += 1
    print count
### BUGGY CODE ###

N = int(input())
A = [int(x) for x in input().split()]
B = [int(y) for y in input().split()]
A_sum = sum(A)

for i in range(N):
    while (A[i+1] != 0 and B[i] != 0):
        if A[i] == 0:
            A[i+1] -= 1
        else:
            A[i] -= 1
        B[i] -= 1

A_after_sum = sum(A)
print(A_sum- A_after_sum)

### FIXED CODE ###

N = int(input())
A = [int(x) for x in input().split()]
B = [int(y) for y in input().split()]
A_sum = sum(A)

for i in range(N):
    while (B[i] != 0 and A[i+1] != 0):
        if A[i] == 0:
            if B[i] <= A[i+1]:
                A[i+1] -= B[i]
                B[i] = 0
            else:
                B[i] -= A[i+1]
                A[i+1] = 0
        else:
            if B[i] <= A[i]:
                A[i] -= B[i]
                B[i] = 0
            else:
                B[i] -= A[i]
                A[i] = 0

A_after_sum = sum(A)
print(A_sum- A_after_sum)
### BUGGY CODE ###

n = int(input())
a = [int(i) for i in input().split()]
b = set(a)
for i in range(n):
    c = a[: i] + a[i + 1 :]
    d = 0
    for j in b:
        e = c.count(j)
        d += (e * (e - 1)) // 2
    print(d)

### FIXED CODE ###

def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    b = {}
    c = set()
    for i in a:
        if i not in b:
            b[i] = 1
        else:
            b[i] += 1
            c.add(i)
    d = 0
    for i in c:
        d += (b[i] * (b[i] - 1)) // 2
    for i in range(n):
        e = d - ((b[a[i]] * (b[a[i]] - 1)) // 2) + (((b[a[i]] - 1) * (b[a[i]] - 2)) // 2)
        print(e)

main()
### BUGGY CODE ###

import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
ans = [0] * n
for i in range(n):
  b = a[i:]+a[:i]
  ans[i] = sum(b[::2]) - sum(b[1::2])
print(*ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
ans = [0] * n
ans[0] = sum(a[::2]) - sum(a[1::2])
for i in range(1,n):
  ans[i] = a[i-1] * 2 - ans[i-1]
print(*ans)
### BUGGY CODE ###

import numpy as np

N,M = map(int,input().split())
A = sorted([int(x) for x in input().split()])
A = np.array(A)

for i in range(M):
    B,C = map(int,input().split())
    
    if int(np.max(A)) <= C:  j,m = B,N
    elif int(np.min(A)) >= C: j,m = 0,0
    else:
        m = len(np.where(A <= C)[0]) - 1
        if B < m:   j = B
        else:   j = m 

    An = np.hstack((A[j:m+1],np.array([C]*j)))
    A = np.hstack((An,A[m+1:N]))

print(int(np.sum(A)))
    

### FIXED CODE ###

import numpy as np

N,M = map(int,input().split())
A = sorted([int(x) for x in input().split()])
An = 0
C = []

for i in range(M):
    C += [[int(x) for x in input().split()]]
    
C = sorted(C,key=lambda x: x[1])[::-1]

m = 0
for i in range(M):
    b = C[i][0]
    if m == N:
        break
    if m+b >= N:
        b = N-m

    if A[m + b - 1] < C[i][1]:
        m = m + b
        An += C[i][1]*b
    else:
        c = C[i][1]
        for j in range(2,b):
            if A[m+b-j] < c:
                m = m + b - j + 1
                An += c*(b-j+1)
                break
        break

if m == N:  print(An)
else:   print(sum(A[m:]) + An)
### BUGGY CODE ###

nq = list(map(int, input().split()))
n = nq[0]
q = nq[1]
s = input()
ac = [0] * (n - 1)
for i in range(n - 1):
    if s[i] == "A" and s[i + 1] == "C":
        ac[i] = 1
for i in range(q):
    lr = list(map(int, input().split()))
    l = lr[0]
    r = lr[1]
    ans = ac[l - 1: r - 1].count(1)
    print(ans)


### FIXED CODE ###

nq = list(map(int, input().split()))
n = nq[0]
q = nq[1]
s = input()
ac_list = []
ac_number = 0
for i in range(n - 1):
    if s[i : i+2] == "AC":
        ac_number += 1
    ac_list.append(ac_number)
ac_list.append(0)
for i in range(q):
    lr = list(map(int, input().split()))
    l = lr[0]
    r = lr[1]
    print(ac_list[r - 2] - ac_list[l - 2])
### BUGGY CODE ###

# coding: utf-8

import sys
import math
import collections
import itertools
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")

N, M = LI()
A = RI(M)

dp = [0] * (N+10)
dp[0] = 1

for i in range(N):
    if i in A:
        continue

    dp[i+1] = (dp[i] + dp[i+1]) % MOD
    dp[i+2] = (dp[i] + dp[i+2]) % MOD

print(dp[N])


### FIXED CODE ###

# coding: utf-8

import sys
def input(): return sys.stdin.readline().strip()

MOD = 10**9 + 7
# N = int(input())
# L = [int(x) for x in input().split()]
N, M = map(int, input().split())
# S = input()

dp = [0] * (N + 5)
dp[0] = 1

for _ in range(M):
    dp[int(input())] = -1

for i in range(N):
    if dp[i] == -1:
        continue
    if dp[i + 1] != -1:
        dp[i + 1] += dp[i]
        dp[i + 1] %= MOD
    if dp[i + 2] != -1:
        dp[i + 2] += dp[i]
        dp[i + 2] %= MOD

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

N=int(input())
ans=[0]*N
for x in range(1,int((N-1)/2)):
    for y in range(x,int((N-1)/2)):
        for z in range(y,int((N-1)/2)):
            if x**2+y**2+z**2+x*y+y*z+z*x<=N:
                if x==y and y==z:
                    ans[x**2+y**2+z**2+x*y+y*z+z*x-1]+=1
                elif x==y or y==z or z==x:
                    ans[x**2+y**2+z**2+x*y+y*z+z*x-1]+=3
                else:
                    ans[x**2+y**2+z**2+x*y+y*z+z*x-1]+=6
            else:
                continue
for n in range(N):
    print(ans[n])


### FIXED CODE ###

N=int(input())
ans=[0]*N
for x in range(1,int((N-1)/2)):
    for y in range(x,int((N-1)/2)):
        if x ** 2 + y ** 2 + 1 ** 2 + x * y + y * 1 + 1 * x > N:
            break
        for z in range(y,int((N-1)/2)):
            if x**2+y**2+z**2+x*y+y*z+z*x<=N:
                if x==y and y==z:
                    ans[x**2+y**2+z**2+x*y+y*z+z*x-1]+=1
                elif x==y or y==z or z==x:
                    ans[x**2+y**2+z**2+x*y+y*z+z*x-1]+=3
                else:
                    ans[x**2+y**2+z**2+x*y+y*z+z*x-1]+=6
            else:
                break

for n in range(N):
    print(ans[n])
### BUGGY CODE ###

def main():
    n, W, *wv = map(int, open(0).read().split())
    dp = [-1] * (W + 1)
    dp[0] = 0
    for i in range(n):
        w = wv[i * 2]
        v = wv[i * 2 + 1]
        for j in range(W - w, -1, -1):
            if dp[j] == -1:
                continue
            dp[j + w] = max(dp[j] + v, dp[j + w])
        #print(dp)
    print(max(dp))

main()

### FIXED CODE ###

from numpy import zeros, maximum            
                                            
n, W, *wv = map(int, open(0).read().split())
t = zeros(W+1, int)                         
for i in range(n):                          
    w = wv[i * 2]                           
    v = wv[i * 2 + 1]                       
    t[w:] = maximum(t[w:], t[:-w]+v)        
print(t[-1])
### BUGGY CODE ###

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

inf = 10**18
ans = 1

if 0 in a:
    ans = 0
else:
    for i in a:
        ans *= i

print(ans if ans <= inf else -1)


### FIXED CODE ###

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

inf = 10**18
ans = 1

sorted(a, reverse=True)
if 0 in a:
    print(0)
    exit()
else:
    for i in a:
        ans *= i
        if ans > inf:
            print(-1)
            exit()

print(ans)