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

from collections import deque
import sys
input = sys.stdin.readline

H, W = list(map(int, input().split()))
S = ["#" * (W+2)] + ["#" + input().strip() +
                     "#" for _ in range(H)] + ["#" * (W+2)]

ans = 0

for j in range(1, H+1):
    for i in range(1, W+1):
        if S[j][i] != ".":
            continue
        m = [[-1] * (W+2) for _ in range(H+2)]

        q = deque()
        q.append((j, i, 0))

        while q:
            y, x, v = q.popleft()
            m[y][x] = v
            for d in ((y, x + 1), (y, x-1), (y+1, x), (y-1, x)):
                dj, di = d
                if S[dj][di] == "." and m[dj][di] == -1:
                    q.append((dj, di, v+1))
                    if ans < v+1:
                        ans = v+1
print(ans)


### FIXED CODE ###

from collections import deque
import sys
input = sys.stdin.readline

H, W = list(map(int, input().split()))
S = ["#" * (W+2)] + ["#" + input().strip() +
                     "#" for _ in range(H)] + ["#" * (W+2)]

ans = 0

for j in range(1, H+1):
    for i in range(1, W+1):
        if S[j][i] != ".":
            continue
        m = [[-1] * (W+2) for _ in range(H+2)]

        q = deque()
        q.append((j, i, 0))
        m[j][i] = 0

        while q:
            y, x, v = q.popleft()
            if ans < v:
                ans = v
            for dj, di in ((y, x+1), (y, x-1), (y+1, x), (y-1, x)):
                if S[dj][di] == "#" or m[dj][di] != -1:
                    continue
                q.append((dj, di, v+1))
                m[dj][di] = v+1
print(ans)
### BUGGY CODE ###

from collections import defaultdict

MOD = 10 ** 9 + 7
def main():
    N = int(input())
    A_list = list(sorted(list(map(int, input().split()))))

    num_of_zero = A_list.count(0)
    if N % 2 == 0:
        if num_of_zero != 0:
            print(0)
            return
    else:
        if num_of_zero != 1:
            print(0)
            return
    for i in range(N - 1, 0, -2):
        if A_list.count(i) != 2:
            print(0)
            return

    print(pow(2, (N // 2), MOD))

if __name__ == '__main__':
    main()


### FIXED CODE ###

from collections import defaultdict
from collections import Counter

MOD = 10 ** 9 + 7
def main():
    N = int(input())
    c = Counter(list(map(int, input().split())))

    if N % 2 == 0 and c[0] != 0:
        print(0)
        return
    if N % 2 != 0 and c[0] != 1:
        print(0)
        return
    for i in range(N - 1, 0, -2):
        if c[i] != 2:
            print(0)
            return

    print(pow(2, (N // 2), MOD))

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

N = int(input())
A = [0] * N
A = list(map(int,input().split()))

ans = 0
mod = 10**9+7
# for i in range(N-1):
#     for j in range(i+1,N):
#         ans += (A[i]%mod) * (A[j]%mod)
#         ans %= mod

# A = list(map(lambda x: x %mod,A))
for i in range(N-1):
    for j in range(i+1,N):
        ans += A[i] * A[j]
        ans %= mod
print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
B = [0] * (N+1)

# 累積和を使う
for i in range(1,N+1):
    B[i] = A[i-1]+B[i-1]
# 累積和の配列完成
# print(B) 

ans = 0
MOD = 10**9+7
for i in range(N):
    ans += A[i] * (B[N] - B[i+1])
    ans %= MOD
print(ans)
### BUGGY CODE ###

n = int(input())
s = input()
ans = 0

for i in range(0, 1000):
    count = 0
    val = str(i).zfill(3)
    for j in s:
        if j == val[count]:
            count += 1
            if count == 3:
                ans += 1
                break
print(ans)



### FIXED CODE ###

n = int(input())
s = list(input())
ans = 0

for i in range(0, 1000):
    count = 0
    val = list(str(i).zfill(3))
    k = val[count]
    for j in s:
        if j == k:
            count += 1
            if count <= 2:
                k = val[count]
            elif count == 3:
                ans += 1
                break
print(ans)
### BUGGY CODE ###

#https://atcoder.jp/contests/abc077/tasks/arc084_a
N = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = 0
a.sort()
b.sort()
c.sort()
for bi in b:
    ai = 0
    ci = N-1
    while ai < N and a[ai] < bi:
        ai += 1
    while ci >= 0 and c[ci] > bi:
        ci -= 1
    ans += ai * (N - 1 -ci)
print(ans)


### FIXED CODE ###

#https://atcoder.jp/contests/abc077/tasks/arc084_a
N = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = 0
a.sort()
b.sort()
c.sort()
ai = 0
ci = 0
for bi in b:
    while ai < N and a[ai] < bi:
        ai += 1
    while ci < N and c[ci] <= bi:
        ci += 1
    ans += ai * (N -ci)
print(ans)
### BUGGY CODE ###


def sieve_eratosthenes(n):
    primes = [0, 1] * (n // 2 + 1)
    if n % 2 == 0:
        primes.pop()
    primes[1] = 0
    primes[2] = 1
    for p in range(3, n + 1, 2):
        if primes[p]:
            for q in range(p * p, n + 1, 2 * p):
                primes[q] = 0
    return [i for i, p in enumerate(primes) if p]


def main():
    N = int(input())
    prime = sieve_eratosthenes(N + 1)

    X = [i for i in range(N + 1)]
    cnt = [1] * (N + 1)
    for p in prime:
        for i in range(p, N + 1, p):
            tmp = 0
            while X[i] % p == 0:
                tmp += 1
                X[i] //= p
            cnt[i] *= tmp + 1

    ans = sum(i * x for i, x in enumerate(cnt[1:], 1))
    print(ans)


if __name__ == "__main__":
    main()

### FIXED CODE ###

N = int(input())
ans = 0

for i in range(1, N + 1):
    n = N // i
    ans += i * n * (n + 1) // 2

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

n, k = map(int, input().split())
p_bef = list(map(int, input().split()))
p_aft = []
a = 0
for i in range(n-k+1):
   for j in range(i, i+k):
      a += p_bef[j]
   p_aft.append(a)
   a = 0
p_aft2 = sorted(p_aft, reverse = True)
print((p_aft2[0]+k)/2)

### FIXED CODE ###

n, k = list(map(int, input().split()))
P = list(map(int, input().split()))
Q = [(p+1)/2 for p in P]
c = [0]
for q in Q:
   c.append(c[-1]+q)
ans = 0
for i in range(k, n+1):
   ans = max(ans, c[i] - c[i-k])
print(ans)
### BUGGY CODE ###

import sys
from collections import deque


input = lambda: sys.stdin.readline().rstrip()


if __name__ == "__main__":
    H, W = map(int, input().split())
    ch, cw = map(lambda x: int(x)+1, input().split())
    dh, dw = map(lambda x: int(x)+1, input().split())
    maze = ["#"*(W+4), "#"*(W+4)]
    maze += [list("##"+input()+"##") for _ in range(H)]
    maze += ["#"*(W+4), "#"*(W+4)]
    INF = 10**8
    mc = [[INF]*(W+4) for _ in range(H+4)]
    mc[ch][cw] = 0
    walk = [(1, 0), (0, 1), (-1, 0), (0, -1)]
    warp = [(y, x) for x in range(-2, 3) for y in range(-2, 3) if abs(y) + abs(x) > 1]
    que = deque()
    que.append((ch, cw, 0))
    while que:
        y, x, w = que.popleft()
        if mc[y][x] < w:
            continue
        for dy, dx in walk:
            ny = y + dy
            nx = x + dx
            if maze[ny][nx] == "." and mc[ny][nx] > w:
                mc[ny][nx] = w
                que.appendleft((ny, nx, w))
        for dy, dx in warp:
            ny = y + dy
            nx = x + dx
            if maze[ny][nx] == "." and mc[ny][nx] > w+1:
                mc[ny][nx] = w+1
                que.append((ny, nx, w+1))
    if mc[dh][dw] == INF:
        print(-1)
    else:
        print(mc[dh][dw])


### FIXED CODE ###

import sys
from collections import deque


input = lambda: sys.stdin.readline().rstrip()


if __name__ == "__main__":
    H, W = map(int, input().split())
    ch, cw = map(lambda x: int(x)-1, input().split())
    dh, dw = map(lambda x: int(x)-1, input().split())
    maze = [list(input()) for _ in range(H)]
    INF = 10**8
    mc = [[INF]*W for _ in range(H)]
    mc[ch][cw] = 0
    walk_que = deque()
    walk_que.append((ch, cw, 0))
    while walk_que:
        y, x, w = walk_que.popleft()
        for ny, nx in [(y+1, x), (y-1, x), (y, x+1), (y, x-1)]:
            if H > ny >= 0 and W > nx >= 0 and mc[ny][nx] > w and maze[ny][nx] == ".":
                mc[ny][nx] = w
                walk_que.appendleft((ny, nx, w))
        for dy in range(-2, 3):
            ny = y + dy
            for dx in range(-2, 3):
                nx = x + dx
                if H > ny >= 0 and W > nx >= 0 and mc[ny][nx] > w+1 and maze[ny][nx] == ".":
                    mc[ny][nx] = w + 1
                    walk_que.append((ny, nx, w+1))
    if mc[dh][dw] == INF:
        print(-1)
    else:
        print(mc[dh][dw])
### BUGGY CODE ###

# encoding: utf-8
N, M = list(map(int, input().split()))

# TLE
# Amod = [A for A in map(lambda x: int(x) % M , input().split())]
# ans = 0
# for l in range(len(Amod)):
#     acm = 0
#     for r in range(l, len(Amod)):
#         acm = (acm + Amod[r]) % M
#         if acm == 0: ans += 1

Asym = []

sym = 0
cnt_zero = 0
for i, A in enumerate(map(int, input().split())):
    sym = (sym + A) % M
    if sym > 0: Asym.append(sym)
    else: cnt_zero += 1
    
ans = cnt_zero * (cnt_zero + 1)
for sym in set(Asym):
    Asym.remove(sym)

for sym in set(Asym):
    cnt = Asym.count(sym)
    ans += cnt * (cnt + 1)
        
print(int(ans / 2))

### FIXED CODE ###

# encoding: utf-8
N, M = list(map(int, input().split()))

d_sym = {}
sym = 0

# refresh

ans = 0
for A in map(int, input().split()):
    sym = (sym + A) % M
    #
    if sym == 0: ans += 1
    # 
    if str(sym) in d_sym.keys(): d_sym[str(sym)] += 1
    else: d_sym[str(sym)] = 1

print(int(ans + sum([val * (val - 1) / 2 for val in d_sym.values()])))
### BUGGY CODE ###

k, q = map(int, input().split())
d = list(map(int, input().split()))
for i in range(q):
  n, x, m = map(int, input().split())
  x %= m
  d_mod = []
  for i in d:
    i_mod = i % m
    if i_mod == 0:
      d_mod.append(m)
    else:
      d_mod.append(i_mod)
  d_mod_sum = sum(d_mod)
  rep = (n-1) // k
  rem = (n-1) % k
  rem_sum = sum(d_mod[:rem])
  ans = n - 1 - (x + d_mod_sum * rep + rem_sum) // m
  print(ans)

### FIXED CODE ###

def main():
  import numpy as np
  k, q = map(int, input().split())
  d = np.array(list(map(int, input().split())))
  for i in range(q):
    n, x, m = map(int, input().split())
    x %= m
    d_mod = d % m
    zero_d = k - np.count_nonzero(d_mod)
    d_mod_sum = np.sum(d_mod) + m * zero_d
    rep = (n-1) // k
    rem = (n-1) % k
    zero_rem = len(d_mod[:rem]) - np.count_nonzero(d_mod[:rem])
    rem_sum = np.sum(d_mod[:rem]) + m * zero_rem
    ans = n - 1 - (x + d_mod_sum * rep + rem_sum) // m
    print(ans)
if __name__ == '__main__':
  main()
### BUGGY CODE ###

H, N = map(int, input().split())
AB = [list(map(int, input().split())) for a in range(N)]

A = [ab[0] for ab in AB]
B = [ab[1] for ab in AB]

INF = 100000000000
# dp[i] : 体力をi減らすための魔力の最小値
dp = [ INF for _ in range(H+max(A)+1)]
dp[0] = 0

for i in range(H+max(A)+1):
  for j in range(N):
    if A[j] <= i:
      dp[i] = min(dp[i], dp[i-A[j]] + B[j])
    else:
      dp[i] = min(dp[i], B[j])

print(min(dp[H::H+max(A)+1]))

### FIXED CODE ###

H, N = map(int, input().split())
dp = [ 1001001001 for _ in range(H+1)]
dp[0] = 0
for i in range(N):
  A, B = map(int, input().split())
  for j in range(H):
    nj = min(j+A, H)
    dp[nj] = min(dp[nj], dp[j] + B)

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

import copy


if __name__ == '__main__':
    N = int(input())
    X_list = list(map(int, input().split()))

    answer = -1
    for i in range(0, N):
        tmp_X_list = copy.deepcopy(X_list)
        del(tmp_X_list[i])
        tmp_X_list = sorted(tmp_X_list)
        answer = tmp_X_list[N//2-1]
        print(answer)


### FIXED CODE ###

import copy


if __name__ == '__main__':
    N = int(input())
    X_list = list(map(int, input().split()))
    tmp_X_list = copy.deepcopy(X_list)
    tmp_X_list = sorted(tmp_X_list)
    med_minus1 = tmp_X_list[N//2-1]
    med_plus1 = tmp_X_list[N//2]

    answer = -1
    for i in range(0, N):
        if X_list[i] <= med_minus1:
            answer = med_plus1
        elif X_list[i] >= med_plus1:
            answer = med_minus1

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

# -*- coding: utf-8 -*-
from sys import stdin
# import numpy as np

s_in = lambda: stdin.readline()[:-1]  # s = s_in()
d_in = lambda: int(stdin.readline())  # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split()))  # List = ds_in()


N, Q = ds_in()
S = s_in()
move_list = []
for _ in range(Q):
    t, d = s_in().split()
    move_list.append([t, d])


def disappear(place):
    if place == -1:
        return (False, False)
    else:
        left = False
        right = False
        for i in range(Q):
            current_char = S[place]
            t, d = move_list[i]
            if t == current_char:
                if d == 'R':
                    place += 1
                else:
                    place -= 1
                if place < 0:
                    left = True
                    break
                elif place > N-1:
                    right = True
                    break
        return (left, right)


def bisect_left():
    start, end = -1, N
    while end - start > 1:
        t = start + (end-start)//2
        if disappear(t)[0]:
            start = t
        else:
            end = t
    return start


def bisect_right():
    start, end = -1, N
    while end - start > 1:
        t = start + (end-start)//2
        if disappear(t)[1]:
            end = t
        else:
            start = t
    return start


left = bisect_left()
right = bisect_right()
print(right - left)


### FIXED CODE ###

# -*- coding: utf-8 -*-
from sys import stdin
# import numpy as np

s_in = lambda: stdin.readline()[:-1]  # s = s_in()
d_in = lambda: int(stdin.readline())  # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split()))  # List = ds_in()


N, Q = ds_in()
S = s_in()
move_list = []
for _ in range(Q):
    t, d = s_in().split()
    move_list.append([t, d])


def disappear(place, array):
    if place == -1:
        return (False, False)
    else:
        left = False
        right = False
        for i in range(Q):
            current_char = array[place]
            t, d = move_list[i]
            if t == current_char:
                if d == 'R':
                    place += 1
                else:
                    place -= 1
                if place < 0:
                    left = True
                    break
                elif place > N-1:
                    right = True
                    break
        return (left, right)


def bisect_left(array):
    start, end = -1, N
    while end - start > 1:
        t = start + (end-start)//2
        if disappear(t, array)[0]:
            start = t
        else:
            end = t
    return start


def bisect_right(array):
    start, end = -1, N
    while end - start > 1:
        t = start + (end-start)//2
        if disappear(t, array)[1]:
            end = t
        else:
            start = t
    return start


list_s = list(S)
left = bisect_left(list_s)
right = bisect_right(list_s)
print(right - left)
### BUGGY CODE ###

n=int(input())
x=0
for i in range(n):
  x+=i
print(x)
  

### FIXED CODE ###

n=int(input())
print(n*(n-1)//2)
### BUGGY CODE ###

# C
n, q = map(int, input().split())
a = input()
s = [0]*(n+1)

for i in range(n+1):
    s[i] = a[:i].count('AC')
    
ans = []
for j in range(q):
    l, r = map(int, input().split())
    ans.append(s[r]-s[l])
    
for v in ans:
    print(v)

### FIXED CODE ###

n, q = map(int, input().split())
s = input()

a = [0]*(n)
for j in range(1, n):
    if s[j-1] == 'A' and s[j] == 'C':
        a[j] += 1
        
csum = [0]*(n+1)
for i in range(n):
    csum[i+1] = csum[i] + a[i]

for i in range(q):
    l, r = map(int, input().split())
    print(csum[r]-csum[l])
### BUGGY CODE ###

x = int(input())
for i in range(-1000000, 1000000):
    for j in range(-1000000, 1000000):
        if i**5 - j**5 == x:
            print(str(i) + " " + str(j))
            exit()

### FIXED CODE ###

x = int(input())
for i in range(-1000, 1000):
    for j in range(-1000, 1000):
        if i**5 - j**5 == x:
            print(str(i) + " " + str(j))
            exit()
### BUGGY CODE ###

def main():
    N = int(input())
    S = list(str(input()))
    sum = 0
    for i in range(0, N-2):
        si = S[i]
        for j in range(i, N-1):
            sj = S[j]
            if si != sj:
                for k in range(j, N):
                    sk = S[k]
                    if j - i != k -j and si != sk and sj != sk:
                        sum += 1
    print(sum)

main()

### FIXED CODE ###

def main():
    N = int(input())
    S = list(str(input()))
    sum = S.count("R") * S.count("G") * S.count("B")
    for i in range(0, N-2):
        si = S[i]
        for j in range(i+1, N-1):
            sj = S[j]
            k = 2*j -i  # Nを超える
            if k < N:
                sk = S[k]
                #if j - i != k -j and si != sj and si != sk and sj != sk:
                if si != sj and si != sk and sj != sk:
                    sum -= 1
    print(sum)

    # 提出 #11871188


main()
### BUGGY CODE ###

x = int(input())
sign = ((1,1),(1,-1),(-1,1),(1,1))
isloop=True
for a in range(10**5):
    if(isloop==False):
        break
    for b in range(10**5):
        if(isloop==False):
            break
        for s1,s2 in sign:
            if(isloop==False):
                break
            a1 = s1*a
            b1 = s2*b
            if((a1**5)==(x+b1**5)):
                print(a1,b1)
                isloop=False
                break
            
        

### FIXED CODE ###

x = int(input())
sign = ((1,1),(1,-1),(-1,1),(-1,-1))
isloop=True
for a in range(10**3):
    if(isloop==False):
        break
    for b in range(10**3):
        if(isloop==False):
            break
        for s1,s2 in sign:
            if(isloop==False):
                break
            a1 = s1*a
            b1 = s2*b
            if((a1**5)==(x+b1**5)):
                print(a1,b1)
                isloop=False
                break
### BUGGY CODE ###

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

for i in range(k):
    tmp = [0] * n
    for j in range(n):
        for k in range(a[j]*2+1):
            if (j - a[j] + k) >= 0 and (j - a[j] + k) < n:
                tmp[(j - a[j] + k)] += 1
    a = tmp

print(' '.join(map(str, a)))


# 10 5
# 20 8
# 40 10
# 80 12
# 160 15

### FIXED CODE ###

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

for i in range(k):
    s = [0] * (n + 1)
    for j in range(n):
        l = max(0, j - a[j])
        r = min(n, j + a[j]+1)
        s[l] += 1
        s[r] += -1
    m = s[0]
    for j in range(1,n+1):
        s[j] += s[j-1]
        if j < n:
            m = min(m, s[j])
    a = s[:-1]
    if m == n:
        print(' '.join(map(str, a)))
        exit()
print(' '.join(map(str, a)))
### BUGGY CODE ###

import math
import numpy as np
x = int(input())
height = list(map(lambda x: int(x), input().split()))  
cands = []


results = []
for i in range(len(height)):
  tmp = []
  cands.append(tmp)
  
# j < k
def check(j, k):
  return k - j == height[j]+ height[k]

  
for i in range(len(height)):
  if i-height[i] >= 0:
    for j in cands[i-height[i]]:
      if check(j, i):
        results.append([j, i])
      
  if i+height[i] < len(height):
    cands[i+height[i]].append(i)

if len(results) > 1:
  #results = np.sort(results, axis=1)
  results = np.unique(results, axis=0)
print(len(results))
	    


### FIXED CODE ###

import math
import numpy as np
x = int(input())
height = list(map(lambda x: int(x), input().split()))  
cands = [0 for i in range(len(height))]


count = 0
  
for i in range(len(height)):
  if i-height[i] >= 0:
    count += cands[i-height[i]]
      
  if i+height[i] < len(height):
    cands[i+height[i]] += 1

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

# ABC093B - Small and Large Integers
a, b, k = list(map(int, input().rstrip().split()))
lst = []
ans = []
for i in range(a, b + 1):
    lst.append(i)
if k >= b - a:
    for i in range(a, b + 1):
        print(i)
else:
    for i in range(k):
        ans.append(a + i)
    for j in range(k):
        if b - j not in ans:
            ans.append(b - j)
    ans = sorted(ans)
    for k in ans:
        print(k)

### FIXED CODE ###

# ABC093B - Small and Large Integers
a, b, k = list(map(int, input().rstrip().split()))
ans = []

if k >= b - a:
    for i in range(a, b + 1):
        print(i)
else:
    for i in range(k):
        ans.append(a + i)
    for j in range(k):
        if b - j not in ans:
            ans.append(b - j)
    ans = sorted(ans)
    for k in ans:
        print(k)
### BUGGY CODE ###

from functools import reduce
from operator import mul

MOD = 1000000007


def combination(n, r):
  r = min(n - r, r)
  if r == 0:
    return 1
  over = reduce(mul, range(n, n - r, -1))
  under = reduce(mul, range(1, r + 1))

  return over // under


def main():
  N, M, K = [int(i) for i in input().strip().split(' ')]
  c = combination(N * M - 2, K - 2) % MOD

  X = sum([(M - i) * i for i in range(M)])
  Y = sum([(N - i) * i for i in range(N)])
  total = X * (N ** 2) + Y * (M ** 2) % MOD
  total = total * c % MOD
  print(total)


main()

### FIXED CODE ###

def mfactorial(n: int, mod: int) -> int:
  cache = mfactorial.__cache if hasattr(mfactorial, '__cache') else [1, 1]
  n_len = len(cache)
  n_new = n - n_len + 1
  if n_new > 0:
    cache = cache + ([0] * n_new)
    for i in range(n_len, n + 1):
      cache[i] = cache[i - 1] * i % mod
    mfactorial.__cache = cache

  return mfactorial.__cache[n]


def cmb(n, r, mod):
  result = mfactorial(n, mod)
  result *= pow(mfactorial(r, mod), mod - 2, mod) % mod
  result %= mod
  result *= pow(mfactorial(n - r, mod), mod - 2, mod) % mod
  result %= mod

  return result


def main():
  MOD = 10 ** 9 + 7

  N, M, K = [int(i) for i in input().strip().split(' ')]
  c = cmb(N * M - 2, K - 2, MOD)

  X = 0
  Y = 0
  for i in range(M):
    X += (M - i) * i
  for i in range(N):
    Y += (N - i) * i

  total = (X * (N ** 2) + Y * (M ** 2)) % MOD * c % MOD
  print(total)


main()
### BUGGY CODE ###

import numpy as np
n=int(input())
a=[0]*2
total=1
a=([int(x) for x in input().split()])
for i in range(n):
    total=total*a[i]

if total<=10**18:
    print(total)
else:
    print("-1")
                                                                             
                                                                             
                                                                             
                                                                             
                                                                             
                                                                             
                                                                             
                                                                             
                                                                             
                                                                             
                                                                             
                                                                             
                                                                             

### FIXED CODE ###

#b問題
n=int(input())
ans=1
a=list(int(y) for y in input().split())
# print(a)
if 0 in a:
    print(0)
else:
    for i in range(n):
        ans*=a[i]
        if ans>10**18:
            ans=-1
            break
    print(ans)