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

H, W = map(int, input().split())
S = []
for i in range(H):
  S.append(list(str(input())))
import numpy as np
S = np.array(S)

left = np.zeros((H, W))
right = np.zeros((H, W))
up = np.zeros((H, W))
down = np.zeros((H, W))

for i in range(H):
  point = 0
  for j in range(W):
    if S[i, j] == ".":
      point += 1
      left[i, j] = point
    elif S[i, j] == "#":
      point = 0

for i in range(H):
  point = 0
  for j in range(W-1, -1, -1):
    if S[i, j] == ".":
      point += 1
      right[i,j] = point
    elif S[i, j] == "#":
      point = 0
    
for i in range(W):
  point = 0
  for j in range(H):
    if S[j, i] == ".":
      point += 1
      up[j, i] = point
    elif S[j, i] == "#":
      point = 0
      
for i in range(W):
  point = 0
  for j in range(H-1, -1, -1):
    if S[j, i] == ".":
      point += 1
      down[j, i] = point
    elif S[j, i] == "#":
      point = 0
score = right + left + up + down
print(int(np.max(score)-3))

### FIXED CODE ###

import numpy as np 
H, W = map(int, input().split())
S = np.array([list(input()) for _ in range(H)]) == '.'
 

up = np.zeros((H, W), dtype=int)
down = np.zeros((H, W), dtype=int)
left = np.zeros((H, W), dtype=int)
right = np.zeros((H, W), dtype=int)
 
for i in range(H):
    up[i] = (up[i-1] + 1) * S[i]
    down[-i-1] = (down[-i] + 1) * S[-i-1]
    
for i in range(W):
    left[:, i] = (left[:, i-1] + 1) * S[:, i]
    right[:, -i-1] = (right[:, -i] + 1) * S[:, -i-1]

print(np.max(up+down+left+right) - 3)
### BUGGY CODE ###

N = int(input())
A=list(map(int, input().split()))
all=int(sum(A)/2)
ans=[]
for i in range(N):
    index=[]
    for j in range(int(N/2)):
        k=(i+1+2*j)%N
        index.append(A[k])
    x=sum(index)
    ans.append((all-x)*2)
for a in ans:
  print(a)

### FIXED CODE ###

N = int(input())
A=list(map(int, input().split()))
all=int(sum(A)/2)
ans=[]
index=[]
i=0
for j in range(int(N/2)):
    k=(i+1+2*j)%N
    index.append(A[k])    
x=all-sum(index)
ans.append((x)*2)
for i in range(N-1):
    y=A[i]-x
    ans.append((y)*2)
    x=y
for a in ans:
    print(a)
### BUGGY CODE ###

n, m = map(int, input().split())
ary = []
a = []
b = []
ary = [0 for i in range(n)]
chk = [False for i in range(n)]
d = {}
for i in range(m):
	aa, bb = map(int, input().split())
	if aa not in d:
		d[aa] = []
	d[aa].append(bb)
	if bb not in d:
		d[bb] = []
	d[bb].append(aa)

flg = True
e = set()
e.add(1)
#print (d)

chk[0] = True
f = set()
cnt = 0
while True:
	flg = False
	for i in e:
		for j in d[i]:
			if chk[j-1]:
				continue
			if ary[j-1] == 0:
				flg = True
				ary[j-1] = i
				chk[j-1] = True
				cnt += 1
				f.add(j)
	e = f.copy()
	if flg == False:
		break
if cnt < n-1:
	print ("No")
else:
	print ("Yes")
	for i in ary[1:]:
		print(i)


### FIXED CODE ###

from collections import deque
n, m = map(int, input().split())
ary = []
a = []
b = []
ary = [0 for i in range(n)]
chk = [False for i in range(n)]
d = {}
for i in range(m):
	aa, bb = map(int, input().split())
	if aa not in d:
		d[aa] = []
	d[aa].append(bb)
	if bb not in d:
		d[bb] = []
	d[bb].append(aa)

visited = [-1 for i in range(n)]
visited[0] = 0
queue = deque([1])
while queue:
	c = queue.popleft()
	for i in d[c]:
		if visited[i-1] != -1:
			continue
		visited[i-1] = c
		queue.append(i)
for i in visited:
	if i == -1:
		print ("No")
		exit()
print ("Yes")
for i in visited[1:]:
	print (i)
### BUGGY CODE ###

import sys
import time

class Node:
    def __init__(self, key = None):
        self.key = key
        self.left = None
        self.right = None

def insert(key):
    global root
    z = Node(key)
    y = None
    x = root
    while x:
        y = x
        if z.key < x.key:
            x = x.left
        else:
            x = x.right

    if y is None:
        root = z
    elif z.key < y.key:
        y.left = z
    else:
        y.right = z

def find(node, key):
    if node is None:
        return False
    elif node.key == key:
        return True
    else:
        return find(node.left, key) or find(node.right, key)

def inorderTreeWalk(node):
    if node:
        return inorderTreeWalk(node.left) + " " + str(node.key) + inorderTreeWalk(node.right)
    return ""

def preorderTreeWalk(node):
    if node:
        return " " + str(node.key) + preorderTreeWalk(node.left) + preorderTreeWalk(node.right)
    return ""

if __name__ == "__main__":
    lines = sys.stdin.readlines()
    del lines[0]

    root = None
    for line in lines:
        if line[0] == "p":
            print inorderTreeWalk(root)
            print preorderTreeWalk(root)
        else:
            com = line.split()
            if com[0][0] == "i":
                insert(int(com[1]))
            else:
                if find(root, int(com[1])):
                    print "yes"
                else:
                    print "no"

### FIXED CODE ###

import sys

class Node:
    def __init__(self, key):
        self.key = key
        self.parent = None
        self.left = None
        self.right = None

def insert(z):
    global root
    y = None
    x = root
    while x is not None:
        y = x
        if z.key < x.key:
            x = x.left
        else:
            x = x.right
    z.parent = y
    if y is None:
        root = z
    elif z.key < y.key:
        y.left = z
    else:
        y.right = z

def find(node, key):
    if node is None:
        return False
    elif node.key == key:
        return True
    elif node.key > key:
        return find(node.left, key)
    else:
        return find(node.right, key)

def inorderTreeWalk(node):
    global In
    if node:
        inorderTreeWalk(node.left)
        In.append(str(node.key))
        inorderTreeWalk(node.right)

def preorderTreeWalk(node):
    global Pre
    if node:
        Pre.append(str(node.key))
        preorderTreeWalk(node.left)
        preorderTreeWalk(node.right)

if __name__ == "__main__":
    lines = sys.stdin.readlines()
    del lines[0]

    root = None
    for line in lines:
        if line[0] == "p":
            In = []
            Pre = []
            inorderTreeWalk(root)
            print " " + " ".join(map(str, In))
            preorderTreeWalk(root)
            print " " + " ".join(map(str, Pre))
        else:
            com = line.split()
            if com[0][0] == "i":
                insert(Node(int(com[1])))
            else:
                if find(root, int(com[1])):
                    print "yes"
                else:
                    print "no"
### BUGGY CODE ###

n = 50000
c = [1 for i in range(n)]
c[0] = 0
i = 2
while i**2 <= n:
    j = i*2
    while j <= n:
        c[j - 1] = 0
        j += i
    i += 1

while True:
    n = int(input())
    cnt = 0
    if n == 0:
        break
    elif n%2 == 0:
        for i in range(n//2):
            if c[i] == 1 and c[n-i] == 1:
                cnt +=1
    print(cnt*2)



### FIXED CODE ###

n = 50001
is_prime = [i for i in range(n)]
is_prime[0] = is_prime[1] = 0
i = 2
while i**2 <= n:
    j = i*2
    while j < n:
        is_prime[j] = 0
        j += i
    i += 1

prime_set  = set(is_prime)
prime_set.remove(0)
prime_list = sorted(list(prime_set))

while True:
    cnt = 0
    n = int(input())
    if n == 0:
        break
    for i in prime_list:
        if i > n//2:
            break
        if n - i in prime_set:
            cnt += 1
    print(cnt)
### BUGGY CODE ###

import math


n = int(input())
l_a = [int(_) for _ in input().split()]

s_a = [0]*(n+1)
for i in range(1, n+1):
    s_a[i] = s_a[i-1] + l_a[i-1]

l = [[0 for i in range(n+1)] for j in range(n+1)]

for i in range(n):
    l[1][i] = l_a[i]

for j in range(2, n+1):
    for i in range(n-j+1):
        for k in range(i, i+j):
            l[j][i] += (math.factorial(j-1) * (s_a[i+j] - s_a[i]) + \
                       math.factorial(j-1)/math.factorial(k-i) * l[k-i][i] + \
                       math.factorial(j-1)/math.factorial(i+j-1-k) * l[i+j-1-k][k+1]) % \
                       (10**9 + 7)
            l[j][i] = l[j][i] % (10**9 + 7)


print(int(l[n][0]))


### FIXED CODE ###

n = int(input())
a_i = [int(_) for _ in input().split()]

mod = 1000000007
fact = 1
for i in range(n):
    fact = (fact * (i + 1)) % mod

s = [0] * n
s[0] = 1 * fact
for i in range(n-1):
    s[i+1] = (s[i] + (fact * pow(i+2, mod-2, mod)) % mod) % mod

ans = 0
for j in range(n):
    p = (s[j] + s[n-j-1] - fact) % mod
    ans += (p * a_i[j]) % mod
    ans = ans % mod

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

H, W, M = map(int, input().split())
m = [[False] * W for _ in range(H)]
dh = dict()
dw = dict()
for _ in range(M):
    h_, w_ = map(int, input().split())
    m[h_ - 1][w_ - 1] = True
    
    if h_ in dh:
        dh[h_] += 1
    else:
        dh[h_] = 1
        
    if w_ in dw:
        dw[w_] += 1
    else:
        dw[w_] = 1

dhl = list(dh.items())
dhl.sort(key=lambda x: x[1], reverse=True)
dwl = list(dw.items())
dwl.sort(key=lambda x: x[1], reverse=True)

h, w = [], []
maxh = dhl[0][1]
maxw = dwl[0][1]

for i, n in dhl:
    if n == maxh:
        h.append(i)
for i, n in dwl:
    if n == maxw:
        w.append(i)

res = maxh + maxw - 1
for hh in h:
    for ww in w:
        if m[hh - 1][ww - 1] is False:
            res = maxh + maxw
            break

print(res)


### FIXED CODE ###

H, W, M = map(int, input().split())
row = [0] * (H + 1)
col = [0] * (W + 1)

bom = []
for i in range(M):
    h, w = map(int, input().split())
    bom.append([h, w])
    row[h] += 1
    col[w] += 1
 
rmax = max(row)
cmax = max(col)
cnt = row.count(rmax) * col.count(cmax)

for h, w in bom:
    if rmax == row[h] and cmax == col[w]:
        cnt -= 1

print(rmax + cmax - (cnt == 0))
### BUGGY CODE ###

N, M = map(int, input().split())
dic = {i: [] for i in range(1, N + 1)} 
X_list = [None] * M
Y_list = [None] * M
for i in range(M):
  X, Y = map(int, input().split())
  dic[X].append(Y)
  X_list[i] = X
  Y_list[i] = Y
for j in range(1, N + 1):
  dic[j].sort()
for x, y in zip(X_list, Y_list):
  print(str(x).zfill(6)+str(dic[x].index(y) + 1).zfill(6))

### FIXED CODE ###

N, M = map(int, input().split())
XY_list = [[] for i in range(N)]
ans_list = [None] * M
for i in range(M):
  X, Y = map(int, input().split())
  XY_list[X - 1].append((Y, i))
for j, k in enumerate(XY_list):
  k.sort()
  for l, (y, m) in enumerate(k):
    ans_list[m] = str(j + 1).zfill(6) + str(l + 1).zfill(6)
print(*ans_list, sep = "\n")
### BUGGY CODE ###

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

if N==1:
    if A[0]==A[1]==A[2]:
        print(1)
    else:
        print(0)
    exit()

INF = float('inf')
ans = 0
dp = [[-INF]*(N+1) for _ in range(N+1)]
dp[A[0]][A[1]] = dp[A[1]][A[0]] = 0
maxdp = [max(row) for row in dp]

for i in range(N-1):
    a,b,c = A[i*3+2:i*3+5]
    if a==b==c:
        ans += 1
        continue
    update = []
    if a==b:
        for j in range(1,N+1):
            update.append((j,c, dp[j][a] + 1))
    elif b==c:
        for j in range(1,N+1):
            update.append((j,a, dp[j][b] + 1))
    elif c==a:
        for j in range(1,N+1):
            update.append((j,b, dp[j][c] + 1))
    update.append((a,b, dp[c][c] + 1))
    update.append((b,c, dp[a][a] + 1))
    update.append((c,a, dp[b][b] + 1))
    mx = max(maxdp)
    update.append((a,b, mx))
    update.append((b,c, mx))
    update.append((c,a, mx))
    for j in range(1,N+1):
        update.append((j,a, maxdp[j]))
        update.append((j,b, maxdp[j]))
        update.append((j,c, maxdp[j]))
    for l,m,n in update:
        dp[l][m] = dp[m][l] = max(dp[l][m], dp[m][l], n)
        maxdp[l] = max(maxdp[l], n)
        maxdp[m] = max(maxdp[m], n)

tmp = max(maxdp)
tmp = max(tmp, dp[A[-1]][A[-1]] + 1)
ans += tmp
print(ans)

### FIXED CODE ###

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

if N==1:
    if A[0]==A[1]==A[2]:
        print(1)
    else:
        print(0)
    exit()

INF = float('inf')
ans = 0
dp = [[-INF]*(N+1) for _ in range(N+1)]
dp[A[0]][A[1]] = dp[A[1]][A[0]] = 0
maxdp = [max(row) for row in dp]
use = {A[0], A[1]}

for i in range(N-1):
    a,b,c = A[i*3+2:i*3+5]
    if a==b==c:
        ans += 1
        continue
    update = []
    if a==b:
        for j in use:
            update.append((j,c, max(dp[a][j], dp[j][a]) + 1))
    elif b==c:
        for j in use:
            update.append((j,a, max(dp[b][j], dp[j][b]) + 1))
    elif c==a:
        for j in use:
            update.append((j,b, max(dp[c][j], dp[j][c]) + 1))
    update.append((a,b, dp[c][c] + 1))
    update.append((b,c, dp[a][a] + 1))
    update.append((c,a, dp[b][b] + 1))
    mx = max(maxdp)
    update.append((a,b, mx))
    update.append((b,c, mx))
    update.append((c,a, mx))
    for j in use:
        update.append((j,a, maxdp[j]))
        update.append((j,b, maxdp[j]))
        update.append((j,c, maxdp[j]))
    for l,m,n in update:
        dp[l][m] = dp[m][l] = max(dp[l][m], dp[m][l], n)
        maxdp[l] = max(maxdp[l], n)
        maxdp[m] = max(maxdp[m], n)
    use.add(a)
    use.add(b)
    use.add(c)

tmp = max(maxdp)
tmp = max(tmp, dp[A[-1]][A[-1]] + 1)
ans += tmp
print(ans)
### BUGGY CODE ###

N = int(input())

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

sum = 0
for i in range(N-1):
    tmp = 0
    for j in range(i+1, N):
        tmp = (A[j]+tmp) % 1000000007
    sum += (A[i] * tmp) % 1000000007
print(sum % 1000000007)


### FIXED CODE ###

N = int(input())

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

total = 0
for i in range(N):
    total += A[i]

sum = 0
for i in range(N-1):
    total -= A[i]
    sum += (A[i] * total) % 1000000007
print(sum % 1000000007)
### BUGGY CODE ###

N,P = map(int,input().split())
c = int(P**(1/N))+1
def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1
if N>1 and is_prime(P):
    print(1)
    exit()
while(1):
    if P%(c**N)==0:
        print(c)
        exit()
    c-=1

### FIXED CODE ###

N,P = map(int,input().split())
r = round(P**(1/N))
for i in range(r,0,-1):
    if P%(i**N)==0:
        print(i)
        exit()
### BUGGY CODE ###

n=int(input())
a=1
for num in range(1,n+1):
  a *= num
print(a%(10**9+7))

### FIXED CODE ###

n = int(input())
p = 1
for i in range(1, n+1):
    p = p * i % 1000000007

print(p)
### BUGGY CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

N,M = map(int,readline().split())
A = [0]+list(map(int,readline().split()))
B = list(map(int,read().split()))

for i in range(1,N):
    A[i] += A[i-1]

I = []
X = []
left_init = list(range(1,N))+[0,0]
right_init = list(range(-1,N))
for n in range(M):
    arr = B[n::M]
    # 安いチケットから入れていく -> 連結成分上で採用される
    left = left_init[:]
    right = right_init[:]
    for i in sorted(range(N), key=arr.__getitem__):
        l = left[i-1]
        r = right[i+1]
        left[r] = l; right[l] = r
        # [l,i] x [i,r] に arr[i] を加える
        x = arr[i]
        I.append(l*N+i); X.append(x)
        if i<N-1:
            I.append((i+1)*N+i); X.append(-x)
        if r<N-1:
            I.append(l*N+r+1); X.append(-x)
        if i<N-1 and r<N-1:
            I.append((i+1)*N+r+1); X.append(x)

del B

ticket_sum = [0]*(N*N)
for i,x in zip(I,X):
    ticket_sum[i] += x
    
# 2d累積和
for i in range(N,N*N):
    ticket_sum[i] += ticket_sum[i-N]
for i in range(N*N):
    if i%N:
        ticket_sum[i] += ticket_sum[i-1]

answer = 0
for i in range(N):
    x = A[i]
    for y,t in zip(A[i:],ticket_sum[N*i+i:N*i+N]):
        happy = x-y+t
        if answer < happy:
            answer = happy

print(answer)


### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import itertools

INF=10**10

N,M = map(int,readline().split())
A = [0,0]+list(map(int,readline().split()))
B = [[INF]*M]+[list(map(int,line.split())) for line in readlines()]

for i in range(1,N+1):
    A[i] += A[i-1]

answer = 0
INF = 10**12
diff = [INF]+[0]*N
left = [list(range(-1,N)) for m in range(M)]
arr = [INF,2,1,2]
for i in range(1,N+1):
    for m in range(M):
        p=i; prev_val=0
        q=left[m][p]
        x = B[i][m]
        while prev_val<=x:
            diff[p] += x-prev_val
            diff[q] -= x-prev_val
            p=q; q=left[m][p]
            prev_val=B[p][m]
        left[m][i]=p
    # 出発地点ごとの収入
    ticket_sum = list(itertools.accumulate(diff[::-1]))[::-1]
    for start in range(1,i+1):
        happy = ticket_sum[start] + A[start]-A[i]
        if answer < happy:
            answer = happy

print(answer)
### BUGGY CODE ###

from collections import deque
n = int(input())
l = deque()

for _ in range (n):
    cmd = input().split(' ')
    if cmd[0]=='insert':
        l.appendleft(int(cmd[1]))
    if cmd[0]=='delete':
       if len(l) !=0 and int(cmd[1]) in l:
            l.remove(int(cmd[1]))
    if cmd[0]=='deleteFirst':
        l.popleft()
    if cmd[0]=='deleteLast':
        l.pop()
print(*l)


### FIXED CODE ###

from collections import deque
n = int(input())
l = deque()
for _ in range (n):
    cmd = input().split(' ')
    if cmd[0]=='insert':
        l.appendleft(cmd[1])  
    if cmd[0]=='delete':
        try:l.remove(cmd[1])
        except :pass
    if cmd[0]=='deleteFirst':
        l.popleft()
    if cmd[0]=='deleteLast':
        l.pop()
print(*l)
### BUGGY CODE ###

N, X = map(int, input().split())
x = list(map(int, input().split()))

def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    if x%y:
        while x%y:
            z = x%y
            x, y = y, x
        else:
            return z
    else:
        return y


x.append(X)
x.sort()
# print(x)
# d = []
# for i in range(N):
#     d.append(x[i+1]-x[i])
# print(d)
for i in range(N):
    if i == 0:
        c = x[i+1]-x[i]
    else:
        c = gcd(x[i+1]-x[i], c)
print(c)


### FIXED CODE ###

N, X = map(int, input().split())
x = list(map(int, input().split()))

def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    # if x%y:
    #     while x%y:
    #         z = x%y
    #         x, y = y, x
    #     else:
    #         return z
    # else:
    #     return y
    if y == 0:
        return x
    else:
        return gcd(y, x%y)


x.append(X)
x.sort()
# print(x)
# d = []
# for i in range(N):
#     d.append(x[i+1]-x[i])
# print(d)
for i in range(N):
    if i == 0:
        c = x[i+1]-x[i]
    else:
        c = gcd(x[i+1]-x[i], c)
print(c)
### BUGGY CODE ###

from math import ceil

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    def is_ok(arg):
    # 条件を満たすかどうか？問題ごとに定義
        B = [int(ceil(a/arg))-1 for a in A]
        #print(arg, B)
        if sum(B) <= K:
            return True
        else:
            return False

    def meguru_bisect(ng, ok):
        '''
        初期値のng,okを受け取り,is_okを満たす最小(最大)のokを返す
        まずis_okを定義すべし
        ng ok は  とり得る最小の値-1 とり得る最大の値+1
        最大最小が逆の場合はよしなにひっくり返す
        '''
        while (abs(ok - ng) > 1):
            mid = (ok + ng) // 2
            if is_ok(mid):
                ok = mid
            else:
                ng = mid
        return ok
    
    ans = meguru_bisect(0, int(1e100))
    print(ans)

if __name__ == "__main__":
    main()

### FIXED CODE ###

from math import ceil

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    def is_ok(arg):
    # 条件を満たすかどうか？問題ごとに定義
        B = [int(ceil(a/arg))-1 for a in A]
        #print(arg, B)
        if sum(B) <= K:
            return True
        else:
            return False

    def meguru_bisect(ng, ok):
        '''
        初期値のng,okを受け取り,is_okを満たす最小(最大)のokを返す
        まずis_okを定義すべし
        ng ok は  とり得る最小の値-1 とり得る最大の値+1
        最大最小が逆の場合はよしなにひっくり返す
        '''
        while (abs(ok - ng) > 1):
            mid = (ok + ng) // 2
            if is_ok(mid):
                ok = mid
            else:
                ng = mid
        return ok
    
    ans = meguru_bisect(0, int(1e20))
    print(ans)

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

import numpy as np
import sys
from bisect import bisect_left

def main():
    input = sys.stdin.readline
    N, Q = map(int, input().split())
    closure = []
    for _ in range(N):
        start, end, pos = map(int, input().split())
        closure.append((pos, start, end))

    closure.sort()

    D = [int(input()) for _ in range(Q)]

    ans = np.full(Q, 10**9, dtype=np.int)
    mask = np.full(Q, -1, dtype=np.int)
    for pos, start, end in closure:
        left = bisect_left(D, start - pos)
        right = bisect_left(D, end - pos)

        ans[left:right] = np.minimum(ans[left:right], pos)
        mask[left:right] = pos

    ans = np.minimum(ans, mask)

    return ans


if __name__ == '__main__':
    print(*main(), sep='\n')


### FIXED CODE ###

# ref: https://atcoder.jp/contests/abc128/submissions/5654623

import sys
from bisect import bisect_left

def main():
    input = sys.stdin.readline
    N, Q = map(int, input().split())
    closure = []
    for _ in range(N):
        start, end, pos = map(int, input().split())
        closure.append((pos, start, end))

    closure.sort()

    D = [int(input()) for _ in range(Q)]

    ans = [-1] * Q
    skip = [-1] * Q
    for pos, start, end in closure:
        left = bisect_left(D, start - pos)
        right = bisect_left(D, end - pos)

        while left < right:
            if skip[left] == -1:
                ans[left] = pos
                skip[left] = right
                left += 1
            else:
                left = skip[left]

    return ans


if __name__ == '__main__':
    print(*main(), sep='\n')
### BUGGY CODE ###

from functools import reduce
N = int(input())
A = list(map(int, input().split()))

tar = reduce(lambda x, y: x*y, A)

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


### FIXED CODE ###


import sys
N = int(input())
A = list(map(int, input().split()))
A.sort()
tar = 1
for i in A:
    tar *= i
    if tar > 10 ** 18:
        print('-1')
        sys.exit()

print(tar)