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

"""Coloring Edges on Tree
https://atcoder.jp/contests/abc146/tasks/abc146_d
"""
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 5 + 1)

class Node:
    def __init__(self, num):
        self.num = num
        self.edge = []
        self.edge_color = []


def dfs(node, p):
    # print(node.num, p)
    for e in node.edge:
        used_color = node.edge_color
        if e != p:
            # 子のノードを取得
            child = tree[e]
            child_used_color = child.edge_color

            # このnodeと子のノードでまだ使っていない色を特定
            unused_colors = list(set(colors) - set(used_color + child_used_color))
            if len(unused_colors) == 0:
                color_num = max(colors) + 1
                colors.append(color_num)
            else:
                color_num = unused_colors[0]

            # このノードと、子のノードに使用ずみの色をマーク
            node.edge_color.append(color_num)
            child.edge_color.append(color_num)

            # 答えを記録
            ans['{a} {b}'.format(a=node.num, b=child.num)] = color_num
            ans['{a} {b}'.format(a=child.num, b=node.num)] = color_num

            # 掘る
            dfs(child, node.num)


N = int(input())
ans = {}
colors = [1]

# treeの初期化
tree = []
edges = []
tree.append(Node(0))
for i in range(1, N + 1):
    tree.append(Node(i))
for i in range(N - 1):
    inp = input().split()
    edges.append(inp)
    a, b = map(int, inp)
    tree[a].edge.append(b)
    tree[b].edge.append(a)

dfs(tree[1], -1)


print(len(colors))
for e in edges:
    # print(e)
    print(str(ans.get(' '.join(e))))


### FIXED CODE ###

"""Coloring Edges on Tree
https://atcoder.jp/contests/abc146/tasks/abc146_d
"""
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 5 + 1)

class Node:
    def __init__(self, num):
        self.num = num
        self.edge = set()
        self.edge_color = set()


def dfs(node, c = -1 , p = -1):
    k = 1    
    for e in node.edge:
        if e == p:
            continue
        if k == c:
            k += 1
        # 子のノードを取得
        child = tree[e]

        # 答えを記録
        if a < b:
            ans['{0} {1}'.format(node.num, child.num)] = k
        else:
            ans['{0} {1}'.format(child.num, node.num)] = k
        k += 1

        # 掘る
        dfs(child,k - 1, node.num)


N = int(input())
ans = {}
# colors = {1}

# treeの初期化
tree = [Node(i) for i in range(0, N + 1)]
edges = []
for i in range(N - 1):
    a, b = map(int, input().split())
    tree[a].edge.add(b)
    tree[b].edge.add(a)
    if a < b:
        edges.append('{0} {1}'.format(a, b))
    else:
        edges.append('{0} {1}'.format(b, a))

dfs(tree[1], -1)

# print("edges:{}".format(edges))
# print(max(c))
# print(ans)
count = 0
for node in tree:
    count = max(count, len(node.edge))
print(count)
for edge in edges:
    # print(edge)
    print(str(ans.get(edge)))
### BUGGY CODE ###

from collections import defaultdict
import sys


sys.setrecursionlimit(10 ** 6)


def find_path(adj, to_node, node, parent=None):
    if node == to_node:
        return [to_node]
    path = None
    for child in adj[node]:
        if child == parent:
            continue
        p = find_path(adj, to_node, child, node)
        if p is None:
            continue
        p = [node] + p
        if path is None or len(path) > len(p):
            path = p
    return path


def depth(adj, node, parent=None):
    ret = 0
    for child in adj[node]:
        if child == parent:
            continue
        d = depth(adj, child, node) + 1
        ret = max(ret, d)
    return ret


def main():
    N, U, V = list(map(int, input().split(' ')))
    U -= 1
    V -= 1
    adj = defaultdict(list)
    for _ in range(N - 1):
        A, B = list(map(lambda x: int(x) - 1, input().split(' ')))
        adj[A].append(B)
        adj[B].append(A)
    path = find_path(adj, U, V)  # to U from V
    dist = len(path) - 1
    partial_depth = depth(adj, path[(dist // 2) + 1], path[dist // 2])
    print(partial_depth + (dist // 2))


if __name__ == '__main__':
    main()


### FIXED CODE ###

from collections import defaultdict
import sys


sys.setrecursionlimit(10 ** 6)


def depth(adj, node, parent=None):
    ret = 0
    for child in adj[node]:
        if child == parent:
            continue
        d = depth(adj, child, node) + 1
        ret = max(ret, d)
    return ret


def main():
    N, U, V = list(map(int, input().split(' ')))
    U -= 1
    V -= 1
    adj = defaultdict(list)
    for _ in range(N - 1):
        A, B = list(map(lambda x: int(x) - 1, input().split(' ')))
        adj[A].append(B)
        adj[B].append(A)

    path = [-1] * N

    def find_path_on_tree(to_node, node, parent=None, d=0):
        if node == to_node:
            path[d] = node
            return True
        for child in adj[node]:
            if child == parent:
                continue
            if not find_path_on_tree(to_node, child, node, d + 1):
                continue
            path[d] = node
            return True
        return False

    find_path_on_tree(U, V)  # to U from V
    path = [node for node in path if node != -1]
    dist = len(path) - 1
    partial_depth = depth(adj, path[(dist // 2) + 1], path[dist // 2])
    print(partial_depth + (dist // 2))


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

N = int(input())
count = 0

for i in range(357, N+1):
 
    thr = str(i).count("3")
    fiv = str(i).count("5")
    sev = str(i).count("7")


    if len(str(i)) == thr + fiv + sev:
        if thr > 0:
             if fiv > 0:
                if sev > 0: 
                    count += 1

print(count)

### FIXED CODE ###

from itertools import product

N = int(input())
num_list = ["3", "5", "7"]
count = 0

for i in range(3, 10):
    for t in (product(num_list, repeat=i)):
        check = t.count("3")*t.count("5")*t.count("7")
        if int("".join(t)) <= N and check:
            count += 1


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

import numpy as np

n = int(input())
aa = list(map(int, input().split()))
bb = list(map(int, input().split()))

rates_list = [[],[]]
for i in range(3):
	if aa[i] > bb[i]:
		rates_list[1].append([bb[i], aa[i]])
	else:
		rates_list[0].append([aa[i], bb[i]])

max_d = n
for j in range(2):
	rates = rates_list[j]
	if len(rates) > 0:
		#print(max_d)
		dp = np.zeros(max_d + 1, dtype = int)
		for d in range(max_d + 1):
			dp[d] = max([dp[d - rates[i][0]] + rates[i][1] if d >= rates[i][0] else d for i in range(len(rates))])
		
		max_d = dp[-1]
print(max_d)


### FIXED CODE ###

n = int(input())
aa = list(map(int, input().split()))
bb = list(map(int, input().split()))

rates_list = [[],[]]
for i in range(3):
	if aa[i] > bb[i]:
		rates_list[1].append([bb[i], aa[i]])
	else:
		rates_list[0].append([aa[i], bb[i]])

max_d = n
for j in range(2):
	rates = rates_list[j]
	if len(rates) == 1:
		max_d = (max_d // rates[0][0]) * rates[0][1] + max_d % rates[0][0]
	elif len(rates) == 2:
		val = [rates[0][1] * i for i in range(max_d // rates[0][0] + 1)]
		rest = [max_d - rates[0][0] * i for i in range(max_d // rates[0][0] + 1)]
		val = [val[i] + rates[1][1] * (rest[i] // rates[1][0]) + (rest[i] % rates[1][0]) if rest[i] > 0 else val[i] for i in range(len(val))]
		max_d = max(val)
	elif len(rates) == 3:
		dp = [(d // rates[0][0]) * rates[0][1] + d % rates[0][0] for d in range(max_d + 1)]
		for d in range(1, max_d + 1):
			dp[d] = max([dp[d]] + [dp[d - rates[i][0]] + rates[i][1] if d - rates[i][0] >= 0 else d for i in range(1, len(rates))])
		max_d = dp[-1]
print (max_d)
### BUGGY CODE ###

from collections import defaultdict
from functools import reduce

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

MOD = 10 ** 9 + 7

def mul(a, b):
  return (a * b) % MOD

def power(x, y):
  if y == 1:
    return x % MOD
  elif y % 2 == 0:
    return power(x, y // 2) ** 2 % MOD
  else:
    return power(x, y // 2) ** 2 * x % MOD

def div(a, b):
  return mul(a, power(b, MOD - 2))

def dict1():
  return {0: 1}

numer_cache = defaultdict(dict1)
denom_inv_cache = dict1()

def combinations_count(n, r):
  r = min(r, n - r)
  numer_cache_n = numer_cache[n]
  if r not in numer_cache_n:
    numer_cache_n[r] = mul(numer_cache_n[r - 1], n - r + 1)
  if r not in denom_inv_cache:
    denom_inv_cache[r] = div(denom_inv_cache[r - 1], r)
  return mul(numer_cache_n[r], denom_inv_cache[r])

print(sum(mul(combinations_count(n, i), combinations_count(n - 1, i)) for i in range(min(n, k + 1))) % MOD)


### FIXED CODE ###

from collections import defaultdict
from functools import reduce

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

MOD = 10 ** 9 + 7

def mul(a, b):
  return a * b % MOD

def power(x, y):
  res = 1
  while True:
    if y & 1:
      res = res * x % MOD
    if y == 1:
      return res
    x = x * x % MOD
    y >>= 1

def div(a, b):
  return a * power(b, MOD - 2) % MOD

def dict1():
  return {0: 1}

numer_cache = defaultdict(dict1)
denom_inv_cache = dict1()

def combinations_count(n, r):
  r = min(r, n - r)
  numer_cache_n = numer_cache[n]
  if r not in numer_cache_n:
    numer_cache_n[r] = mul(numer_cache_n[r - 1], n - r + 1)
  if r not in denom_inv_cache:
    denom_inv_cache[r] = div(denom_inv_cache[r - 1], r)
  return mul(numer_cache_n[r], denom_inv_cache[r])

print(sum(mul(combinations_count(n, i), combinations_count(n - 1, i)) for i in range(min(n, k + 1))) % MOD)
### BUGGY CODE ###

from heapq import heappop, heappush

def dijkstra(s):
    used = [1] * n
    dp = [INF] * n
    dp[s] = 0
    hq = []
    used[s] = 0
    for i in cost[s]:
        heappush(hq, i)

    while hq:
        minv = heappop(hq)
        if used[minv[1]] == 0:
            continue
        v = minv[1]
        dp[v] = minv[0]
        used[v] = 0
        for i in cost[v]:
            if used[i[1]]:
                heappush(hq, [i[0] + dp[v], i[1]])
    return dp

INF = 10 ** 18
n, x, y = map(int, input().split())
cost = [[] for _ in range(n)]

for i in range(n - 1):
    a = i
    b = i + 1
    cost[a].append([1, b])
    cost[b].append([1, a])
cost[x - 1].append([1, y - 1])
cost[y - 1].append([1, x - 1])
ans = [0] * n
for i in range(n - 1):
    dp1 = dijkstra(i)
    for j in dp1[i:]:
        ans[j] += 1

for i in ans[1:]:
    print(i)


### FIXED CODE ###

from heapq import heappop, heappush

def dijkstra(s):
    used = [1] * n
    dp = [INF] * n
    dp[s] = 0
    hq = []
    used[s] = 0
    for i in cost[s]:
        heappush(hq, i)

    while hq:
        minv = heappop(hq)
        if used[minv[1]] == 0:
            continue
        v = minv[1]
        dp[v] = minv[0]
        used[v] = 0
        for i in cost[v]:
            if used[i[1]]:
                heappush(hq, [i[0] + dp[v], i[1]])
    return dp

INF = 10 ** 18
n, x, y = map(int, input().split())
cost = [[] for _ in range(n)]

for i in range(n - 1):
    a = i
    b = i + 1
    cost[a].append([1, b])
    cost[b].append([1, a])
cost[x - 1].append([1, y - 1])
cost[y - 1].append([1, x - 1])
ans = [0] * n
for i in range(n - 1):
    dp1 = dijkstra(i)
    for j in dp1[i:]:
        ans[j] += 1

for i in ans[1:]:
    print(i)
### BUGGY CODE ###

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

mod = 1000000007

f = [] # 素因数分解(指数部のみ)

for p in range(2, M): # 素因数分解
    e = 0
    while M%p == 0:
        e += 1
        M /= p
    
    if e>0:
        f.append(e)
    
    if M == 1:
        break

def pw(a, e):
    if e == 1:
        return a
    p = pw(a, e // 2)
    if e%2 == 1:
        return p * p % mod * a % mod
    else:
        return p * p % mod

# fact, inv の計算
fact = [1] * 100040
inv = [1] * 100040
for k in range(1, 100040):
    fact[k] = fact[k-1] * k % mod
    inv[k] = pw(fact[k], mod-2)

def combine(n, k):
    return fact[n] * inv[k] % mod * inv[n-k] % mod

ans = 1
for e in f:
    ans *= combine(e+N-1, e) # N_H_e (重複組合せ)
    ans %= mod

print(ans)


### FIXED CODE ###

from collections import Counter

mod = 1000000007

# nの素因数分解

def prime(n):
    d = Counter()
    i = 2
    while i*i <= n:
        while n%i == 0:
            n //= i
            d[i] += 1
        i += 1
    if n > 1:
        d[n] += 1
    return d

# xのn乗を計算する
def mod_pow(x, n):
    if n == 0:
        return 1
    elif n % 2 == 0:
        half_x = mod_pow(x, n // 2)
        return half_x * half_x % mod
    else:
        return x * mod_pow(x, n-1) % mod

fact = [1] * 100100
inv = [1] * 100100
for k in range(1, 100100):
    fact[k] = fact[k-1] * k % mod
    inv[k] = mod_pow(fact[k], mod-2)

def nCr(n, r):
    return fact[n] * inv[r] % mod * inv[n-r] % mod

def solve():
    N, M = map(int, input().split())
    p = prime(M)
    s = 1
    for i in p.values():
        s *= nCr(i + N - 1, N - 1)
        s %= mod
    print(s)

solve()
### BUGGY CODE ###

n=int(input())
a = list(map(int,input().split()))
mod = 10**9 +7
ans = 0

for i in range(n-1):
    for j in range(i+1,n):
        ans += (a[i] *a[j]) %mod
print(ans%mod)

### FIXED CODE ###

n=int(input())
a = list(map(int,input().split()))
mod = 10**9 +7
s = 0
ss =0
for i in range(n):
    s += a[i]
    ss += a[i] * a[i]

ans = (s*s - ss)//2
print(ans%mod)
### BUGGY CODE ###

def resolve():
    '''
    code here
    '''
    N = int(input())
    A_list = [int(item) for item in input().split()]

    res = 1

    for item in A_list:
        res *= item

    if res > 10 ** 18:
        print(-1)
    else:
        print(res)

if __name__ == "__main__":
    resolve()


### FIXED CODE ###

def resolve():
    '''
    code here
    '''
    N = int(input())
    A_list = [int(item) for item in input().split()]

    is_zero = False
    is_over = False
    res = 1

    for item in A_list:
        if item == 0:
            is_zero = True
            break

    if is_zero:
        print(0)
    else:
        for item in A_list:
            res *= item

            if res > 10 ** 18:
                is_over = True
                break
        else:
            print(res)

        if is_over:
            print(-1)

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

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

count = 0
for i in range(N):
    for j in range(0, i+1):
        if P[i] > P[j]:
            break
    else:
        count += 1

print(count)

### FIXED CODE ###

import sys

N = int(sys.stdin.readline())
P = list(map(int, sys.stdin.readline().split()))

count = 0
min = P[0]
for i in range(N):
    if P[i] <= min:
        min = P[i]
        count += 1
    """
    else:
        for j in range(i+1):
            if P[i] > P[j]:
                break
        else:
            count += 1
    """
print(count)
### BUGGY CODE ###

n = int(input())
l = list(map(int,input().split()))
ans = ''

for i in range(n):
  ans += str(l.index(i+1) + 1) + ' '
print(ans)

### FIXED CODE ###

n = int(input())
l = list(map(int,input().split()))
ans = [0] * n

for i in range(n):
  ans[l[i]-1] = i + 1
print(*ans)
### BUGGY CODE ###

from collections import deque
 
H,W=map(int, input().split())

A=[]
for i in range(H):
  A.append(list(input()))
q=deque([])
for i in range(H):
  for j in range(W):
    if A[i][j] == '#':
      q.append((i, j, 0))

x=-1
while q:
  (i, j, n)=q.popleft()
  x=max(x, n)
  if i > 0 and A[i-1][j] == '.':
    A[i-1][j] = '#'
    q.append((i-1, j, n+1))
  if i < H-1 and A[i+1][j] == '.':
    A[i+1][j] = '#'
    q.append((i+1, j, n+1))
  if j > 0 and A[i][j-1] == '.':
    A[i][j-1] = '#'
    q.append((i, j-1, n+1))
  if j < W-1 and A[i][j+1] == '.':
    A[i][j+1] = '#'
    q.append((i, j+1, n+1))
"""
q=deque([])
for i in range(W*H):
  q.append(i)
  q.append(i)
  q.append(i)
  q.append(i)
  q.popleft()
"""
print(x)

### FIXED CODE ###

def f(h, w):
    dt = [[-1, 0], [0, -1], [0, 1], [1, 0]]
    t = [[True] * (w + 2)]
    for _ in range(h):
        t += [[True] + [(c == "#") for c in input()] + [True]]
    t += [[True] * (w + 2)]
    kuro = []
    for i, ti in enumerate(t[1:-1]):
        for j, tij in enumerate(ti[1:-1]):
            if tij:
                kuro+=[(i + 1, j + 1)]
    cnt = -1
    while kuro:
        cnt += 1
        nxt = []
        for i, j in kuro:
            ti=t[i]
            if not ti[j+1]:
                ti[j + 1]=True
                nxt += [(i, j+1)]
            if not ti[j-1]:
                ti[j - 1]=True
                nxt += [(i, j-1)]
            if not t[i - 1][j]:
                t[i - 1][j]=True
                nxt += [(i - 1, j)]
            if not t[i + 1][j]:
                t[i + 1][j]=True
                nxt += [(i + 1, j)]
        kuro = nxt
    print(cnt)
 
 
h, w = map(int, input().split())
f(h, w)
### BUGGY CODE ###

n = int(input())
a = [int(input()) for _ in range(n)]
a_ = sorted(a)
a_max = a_[-1]
a_second = a_[-2]

if a.count(max(a)) >= 2:
    for _ in range(n):
        print(a_max)
else:
    for _ in range(n):
        if a[_] == max(a):
            print(a_second)
        else:
            print(a_max)


### FIXED CODE ###

n = int(input())
a = [int(input()) for _ in range(n)]
a_ = sorted(a)
a_max = a_[-1]
a_second = a_[-2]
 
if a.count(a_max) >= 2:
    for _ in range(n):
        print(a_max)
else:
    for _ in range(n):
        if a[_] == a_max:
            print(a_second)
        else:
            print(a_max)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
# 整数の入力


def main():
    n = int(input())
    ans = 0
    for i in range(1, n + 1):
        ans += i - 1
    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

# -*- coding: utf-8 -*-
# 整数の入力
from decimal import Decimal


def main():
    n = int(input())

    if n == 1:
        print(0)
        return

    # print(int(n ** 2 - n))
    # print((n ** 2 - n) / 2)
    # print(n * (n - 1))
    # print(n * (n - 1) / 2)
    ans = int(Decimal(n * (n - 1)) / 2)
    print(ans)
    # print(ans * 2)


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

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    for _ in range(K):
        a = [0] * N
        t = 0
        for i in range(N):
            t += a[i] + 1
            if i + A[i] + 1< N:
                a[i + A[i] + 1] -= 1
            a[i] = t
        t = 0
        b = [0] * N
        for i in reversed(range(N)):
            t += b[i]
            b[i] = t
            t += 1
            if i - A[i] - 1 >= 0:
                b[i - A[i] - 1] -= 1
            A[i] = a[i] + b[i]
    return A

print(*main())


### FIXED CODE ###

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    for _ in range(K):
        m = True
        a = [0] * N
        t = 0
        for i in range(N):
            t += a[i] + 1
            if i + A[i] + 1< N:
                a[i + A[i] + 1] -= 1
            a[i] = t
        t = 0
        b = [0] * N
        for i in reversed(range(N)):
            t += b[i]
            b[i] = t
            t += 1
            if i - A[i] - 1 >= 0:
                b[i - A[i] - 1] -= 1
            A[i] = a[i] + b[i]
            if A[i] < N:
                m = False
        if m:
            break
    return A

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

#!/usr/bin/env python

import sys
import re

s= sys.stdin.readline().strip()
n= len(s)
#
c= 0
p1= re.compile("ABC")
p2= re.compile("A+$")
p3= re.compile("^(BC)+")
#
while True:
    m =p1.search( s )
    if not m: break
    i= m.start() + 1
    a=0
    for ch in reversed(s[:i]):
        if ch=="A": a+=1
        else: break
    #
    bc= 1
    j= i+2
    while True:
        k= j+2
        if k>n or s[j:k]!="BC": break
        j += 2
        bc+= 1

    s= ("A"*a) + s[i+2*bc:]
    c+= a*bc

print( c )


### FIXED CODE ###

#!/usr/bin/env python

import sys
import re

s= sys.stdin.readline().strip()
s= s.replace("BC","D")
s= re.sub("[BC]+"," ",s).split()

t= 0
for seg in s:
    a= 0
    for c in seg:
        if c=="A": a+=1
        elif c=="D": t+= a
#
print( t )
### BUGGY CODE ###

import heapq 
import copy
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
r=copy.deepcopy(l)

for i in range(n):
    l[i][0],l[i][1]=-l[i][0],-l[i][1]
    r[i][0],r[i][1]=-r[i][1],-r[i][0]
heapq.heapify(l)
heapq.heapify(r)
ans=0
for i in range(n):
    if i%2==0:
        ans-=l[0][0]*((-1)**i)
        r.remove(l[0][::-1])
        minimum=heapq.heappop(l)
    else:
        ans-=r[0][0]*((-1)**i)
        l.remove(r[0][::-1])
        minimum=heapq.heappop(r)
print(ans)

### FIXED CODE ###

n=int(input())
l=[]
c=0
for i in range(n):
    a,b=map(int,input().split())
    c-=b
    l.append(a+b)
l.sort()
l=l[::-1]
for i in range(0,n,2):
    c+=l[i]
print(c)
### BUGGY CODE ###

from collections import defaultdict
N = int(input())
L = [list(map(lambda x:int(x)-1, input().split())) for _ in range(N)]


def make_hash(a, b):
    a, b = min(a, b), max(a, b)
    return N*a+b


def un_hash(n):
    a = n//N
    b = n % N
    return a, b


from_to = defaultdict(lambda: set())
pointed = defaultdict(int)
pointing = defaultdict(int)

for i in range(N):
    for node_from, node_to in zip(L[i], L[i][1:]):
        #from_to[make_hash(i, node_to)].add(make_hash(i, node_from))
        from_to[make_hash(i, node_from)].add(make_hash(i, node_to))
        pointed[make_hash(i, node_to)] += 1
        pointing[make_hash(i, node_from)] += 1

START = set()
DST = set()
for i in range(N):
    for j in range(i+1, N):
        h = make_hash(i, j)
        pointed_i = pointed[h]
        pointing_i = pointing[h]
        if pointed_i == 0:
            START.add(h)
        if pointing_i == 0:
            DST.add(h)
if len(START) == 0 or len(DST) == 0:
    print(-1)

else:
    Q = [v for v in START]
    visited = set()
    dist = 0
    while Q:
        tmp = []
        dist += 1
        for q in Q:
            for nex in from_to[q]:
                tmp.append(nex)
                visited.add(nex)
        Q = tmp
    print(dist)


### FIXED CODE ###

from collections import deque

n = int(input())
matches = []
for _ in range(n):
    matches.append(list(map(lambda x: int(x)-1, input().split())))

q = deque(range(n))

days = [0]*n  # 各選手の現在の日付
pairs = [-1]*n  # 次の対戦相手を管理(wait的な)

while q:
    x = q.popleft()  # 試合する人
    if len(matches[x]) == 0:  # 試合が全て終わってる?
        continue
    y = matches[x].pop(0)  # xの次の対戦相手
    if pairs[y] == x:
        day = max(days[x], days[y])+1
        days[x] = day
        days[y] = day
        q.append(x)
        q.append(y)
    else:
        pairs[x] = y

if not any(matches):  # 全ての試合をしょうか
    print(max(days))
else:
    print(-1)
### BUGGY CODE ###

import sys
#import numpy as np
import bisect
sys.setrecursionlimit(10 ** 7)

N, Q = map(int, input().split())
STX = []
for _ in range(N):
    s, t, x = map(int, input().split())
    STX.append((s, t, x))

PEOPLE = []
for _ in range(Q):
    d = int(input())
    PEOPLE.append(d)

ans = [-1] * Q

STX.sort(key=lambda x: -x[2])

for s, t, x in STX:
    #print("s,t,x", s, t, x)
    #i = np.searchsorted(PEOPLE, s - x)
    #j = np.searchsorted(PEOPLE, t - x)
    i = bisect.bisect_left(PEOPLE, s - x)
    j = bisect.bisect_left(PEOPLE, t - x)
    #print("i,j", i, j)

    ans[i:j] = [x] * (j-i)

    # for k in range(i, j):
    # if ans[k] == '-1':
    #ans[k] = str(x)

    # print(ans)

print("\n".join(map(str, ans)))


### FIXED CODE ###

#D in [S_i-X_i,T_i-X_i) → Xiで止まる
import sys
input = sys.stdin.readline
from heapq import heappop,heappush
from collections import defaultdict

N,Q = map(int,input().split())
task = []

STX = [[int(x) for x in input().split()] for _ in range(N)]
for s,t,x in STX:
  task.append((t-x,0,x)) # xで止まらなくなる
  task.append((s-x,1,x)) # xで止まる

for i in range(Q):
  d = int(input())
  task.append((d,2,i)) # 止まる位置を答える
answer = [-1]*Q

task.sort()

# 引っかかってる場所の管理
se = set()
se_hp = [] # heapで最小値を先頭に保つ

# 小さい時刻から順に見ていく
for a,b,c in task:
  if not b: # b == 0
    se.remove(c)
  elif b&1: # b == 1
    se.add(c)
    heappush(se_hp,c)
  else: # b == 2
    while se_hp and se_hp[0] not in se:
      heappop(se_hp)
    answer[c] = se_hp[0] if se_hp else -1

print('\n'.join(map(str,answer)))
### BUGGY CODE ###

import functools
import operator

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

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

if (ans > 10**18):
  print(-1)
else:
  print(ans)

### FIXED CODE ###

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

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