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

def g(field,x,y,h,w,ans):
     cnt = 1
     flag = h+w+1
     while cnt < flag:
          for i in range(0,cnt+1):
               j = cnt - i
               search = [[x+i,y+j],[x-i,y+j],[x+i,y-j],[x-i,y-j]]
               #print(search,cnt)
               for p in search:
                    if (1<=p[0]) and (p[0]<=w) and (1<=p[1]) and (p[1]<=h):
                         if field[p[1]][p[0]] == "#":
                              return cnt
                         if ans[p[1]-1][p[0]-1] != "#":
                              flag == min(flag,cnt + ans[p[1]-1][p[0]-1])
          cnt += 1
     return flag


def f():
     h,w = map(int,input().split())
     field = [["!"]*w ]
     for i in range(h):
          field.append(["!"]+list(input())+["!"])
     field.append(["!"]*w)
     ans = [["#"]*w for i in range(h)]
     for i in range(1,h+1):
          for j in range(1,w+1):
               if field[i][j] == "#":
                    ans[i-1][j-1] = 0
               elif field[i][j] == ".":
                    ans[i-1][j-1] = g(field,j,i,h,w,ans)
     a = -1
     for i in range(h):
          #print(ans[i])
          a = max(a,max(ans[i]))
     print(a)
     return
f()

### FIXED CODE ###

def f():
     h,w = map(int,input().split())
     field = []
     for i in range(h):
          field.append(list(input()))
          
     que = []
     for i in range(h):
          for j in range(w):
               if field[i][j] == "#":
                    que.append([i,j])
     if que == []:
          print(0)
          return
     cnt = 0
     while que != []:
          que1 = []
          for p in que:
               for v in [[1,0],[0,1],[-1,0],[0,-1]]:
                    newx,newy = p[1]+v[1],p[0]+v[0]
                    if (0<=newx) and (newx<w) and (0<=newy) and (newy<h):
                         if field[newy][newx] == ".":
                              field[newy][newx] = "#"
                              que1.append([newy,newx])
          que = que1
          cnt += 1
     print(cnt-1)
     return
f()
### BUGGY CODE ###

from math import ceil,sqrt,log,gcd
def ii():return int(input())
def si():return input().strip()
def mi():return map(int,input().split())
def li():return list(mi())
mod=1000000007

n=ii()
s=si()

    
l=0
r=n-1
ans=0
while(l<r):
    f=0
    for i in range(l,n):
        if s[i]=='W':
            l=i
            f=1
            break
    for i in range(r,-1,-1):
        if s[i]=='R':
            r=i
            break
    if(l>=r or f==0):
        break
    ans+=1
    l+=1
    r-=1

print(ans)










### FIXED CODE ###

from math import ceil,sqrt,log,gcd
def ii():return int(input())
def si():return input().strip()
def mi():return map(int,input().split())
def li():return list(mi())
mod=1000000007

n=ii()
s=si()

    
l=0
r=n-1
ans=0
while(l<r):
    f=0
    for i in range(l,n):
        if s[i]=='W':
            l=i
            f=1
            break
    f1=0
    for i in range(r,-1,-1):
        if s[i]=='R':
            r=i
            f1=1
            break
    if(l>=r or f==0 or f1==0):
        break
    ans+=1
    l+=1
    r-=1

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

n = int(input())

def q(i):
    print(i)
    s = str(input())
    if s == 'Vacant':
        exit()
    else:
        return s

x = q(0)

def ok(m):
    if m == 0:
        return False
    else:
        if (m%2 == 0 and q(m) != x) or (m%2 == 1 and q(m) == x):
            return True
        else:
            return False

l = 0
r = n-1
while l+1 < r:
    c = (l+r)//2
    if ok(c):
        r = c
    else:
        l = c

### FIXED CODE ###

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

    def q(i):
        print(i, )
        s = str(input())
        if s == 'Vacant':
            exit()
        else:
            return s

    x = q(n-1)
    x = q(0)

    def ok(m):
        if m == 0:
            return False
        else:
            if (m%2 == 0 and q(m) != x) or (m%2 == 1 and q(m) == x):
                return True
            else:
                return False

    l = 0
    r = n-1
    while l+1 < r:
        c = (l+r)//2
        if ok(c):
            r = c
        else:
            l = c

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

import itertools
N=int(input())
word="0123456789"
number=["".join(i) for i in itertools.product(word,repeat=3)]

S=list(input())
ans=0
for i in number:
    count=0

    for s in range(N):
        if i[count]==S[s]:
            count+=1
            if count==2:
                if i[2] in S[s+1:]:
                    ans+=1
                break


print(ans)




### FIXED CODE ###

def main():
  N = int(input())
  S = list(map(int,input()))
  ans = 0
  for i in range(10):
    for j in range(10):
      for k in range(10):
        flg = False
        flg2 = False
        for x in range(N):
          if flg2:
            break
          if not flg:
            if S[x] == i:
              flg = True
          else:
            if S[x] == j:
              flg2 = True
              if k in S[x+1:]:
                ans +=1
  print(ans)
main()
### BUGGY CODE ###

S = input()
queryNum = input()
flip = False
for i in range(int(queryNum)):
	order = input()
	if order == '1':
		if flip:
			flip = False
		else:
			flip = True
	else:
		if order[2] == '1':
			if not flip:
				S = order[4] + S
			elif flip:
				S = S + order[4]
		else:
			if not flip:
				S = S + order[4]
			elif flip:
				S = order[4] + S
if flip:
	print(S[::-1])
else: 
	print(S)

### FIXED CODE ###

from collections import deque

S = deque(input())
queryNum = input()
flip = False
for i in range(int(queryNum)):
	order = input()
	if order == '1':
		if flip:
			flip = False
		else:
			flip = True
	else:
		if order[2] == '1':
			if not flip:
				S.appendleft(order[4])
			elif flip:
				S.append(order[4])
		else:
			if not flip:
				S.append(order[4])
			elif flip:
				S.appendleft(order[4])
S = ''.join(S)
if flip:
	print(S[::-1])
else: 
	print(S)
### BUGGY CODE ###

from functools import lru_cache
h,w= map(int, input().split())
maze = [[-1 for i in range(w)] for j in range(h)]

ans = 0
for i in range(h):
    maze[i] = input()

INF = 10000

@lru_cache(None)
def dfs(y,x,flg,cnt):
    if y == h-1 and x ==w-1:
        if flg ==1:
            cnt+=1
        return cnt
    ans = [INF]
    for (ny, nx) in [(y+1, x), (y, x+1)]:
        if 0 <= nx < w and 0 <= ny < h:
            if maze[ny][nx] != maze[y][x]:
                if flg == 0: ans.append(dfs(ny,nx,1,cnt))
                else: ans.append(dfs(ny,nx,0,cnt+1))
            else:
                ans.append(dfs(ny,nx,flg,cnt))
    return(min(ans))

print(dfs(0,0,(0 if maze[0][0]=='.' else 1),0))


### FIXED CODE ###

from functools import lru_cache
h,w= map(int, input().split())
maze = [[-1 for i in range(w)] for j in range(h)]

ans = 0
for i in range(h):
    maze[i] = input()

INF = 10000

@lru_cache(None)
def dfs(y,x,flg,cnt):
    if y == h-1 and x ==w-1:
        if flg ==1:
            cnt+=1
        return cnt
    ans = [INF]
    for (ny, nx) in [(y+1, x), (y, x+1)]:
        if 0 <= nx < w and 0 <= ny < h:
            if maze[ny][nx] != maze[y][x]:
                if flg == 0: ans.append(dfs(ny,nx,1,cnt))
                else: ans.append(dfs(ny,nx,0,cnt+1))
            else:
                ans.append(dfs(ny,nx,flg,cnt))
    return(min(ans))

print(dfs(0,0,(0 if maze[0][0]=='.' else 1),0))
### BUGGY CODE ###

from collections import Counter

N = int(input())

s = []
check = []
ans = 0
# for x in range(N):
#     for c in input():
#         s[x].append(c)

for _ in range(N):
    s.append(input())
for x in s:
    check.append(Counter(x))

while check:
    cc = check.pop(0)
    ans += check.count(cc)


print(ans)

### FIXED CODE ###

from collections import Counter

N = int(input())

# check = []
# ans = {}
# answer = 0
# for _ in range(N):
#     s = Counter(input())
#     if s not in check:
#         check.append(s)
#         ans[str(sorted(s.items(), key=lambda x:x[0]))] = 0
#
#     else:
#         ans[str(sorted(s.items(), key=lambda x:x[0]))] += 1
#         answer += ans[str(sorted(s.items(), key=lambda x:x[0]))]
#
# print(answer)

ans = {}
answer = 0
for _ in range(N):
    s = "".join(sorted(input()))

    if s not in ans:
        ans[s] = 0

    else:
        ans[s] += 1
        answer += ans[s]

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

N,M=map(int, input().split())
import sys
def input(): return sys.stdin.readline().strip()
A=list(map(int, input().split()))
BC=[list(map(int,input().split())) for i in range(M)]
A.sort()
BC.sort(key=lambda x: x[1],reverse=True)
from bisect import bisect_left
ans=0
for m in range(M):
    if BC[m][0]<len(A) and A[BC[m][0]]<BC[m][1]:
        ans=ans+BC[m][1]*BC[m][0]
        A=A[BC[m][0]:]
    else:    
        r=bisect_left(A,BC[m][1])
        if r:
            ans=ans+BC[m][1]*r
            A=A[r:]
        break
ans+=sum(A)
print(ans)

### FIXED CODE ###

N,M=map(int, input().split())
import sys
def input(): return sys.stdin.readline().strip()
A=list(map(int, input().split()))
BC=[list(map(int,input().split())) for i in range(M)]
A.sort()
BC.sort(key=lambda x: x[1],reverse=True)
from bisect import bisect_left
ans=0
l=0
for m in range(M):
    if BC[m][0]<len(A)-l and A[BC[m][0]+l]<BC[m][1]:
        ans=ans+BC[m][1]*BC[m][0]
        l+=BC[m][0]
    else:     
        r=bisect_left(A[l:],BC[m][1])
        if r:
            ans=ans+BC[m][1]*r
            l+=r
        break
ans+=sum(A[l:])
print(ans)
### BUGGY CODE ###

n, k = (int(x) for x in input().split())
seq = [int(x) for x in input().split()]
ans = 0
for i in range(n-k+1):
  score = 0 
  for j in range(k):
    n = seq[i+j]
    score += 1/2*(2+(n-1)) 
  ans = max(ans, score)
  
print(round(ans, 9))

### FIXED CODE ###

n, k = (int(x) for x in input().split())
seq = [int(x) for x in input().split()]

ans = 0
for i in range(k):
    ans += 1/2*(2+(seq[i]-1)) 
score = ans
for i in range(n-k):
  score -= 1/2*(2+(seq[i]-1)) 
  score += 1/2*(2+(seq[i+k]-1)) 
  ans = max(ans, score)
  
print(round(ans, 9))
### BUGGY CODE ###

R, C, k = map(int, input().split())
xs = [[0] * C for _ in range(R)]
for _ in range(k):
    r, c, v = map(int, input().split())
    xs[r - 1][c - 1] = v

dp = [[[0] * 4 for _ in range(C + 1)] for _ in range(R + 1)]
for i in range(R):
    for j in range(C):
        for k in range(2, -1, -1):
            dp[i][j][k + 1] = max(dp[i][j][k + 1], dp[i][j][k] + xs[i][j])
        for k in range(4):
            dp[i][j + 1][k] = max(dp[i][j + 1][k], dp[i][j][k])
            dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][k])
print(max(dp[R - 1][C - 1]))


### FIXED CODE ###

R, C, k = map(int, input().split())
xs = [[0] * C for _ in range(R)]
for _ in range(k):
    r, c, v = map(int, input().split())
    xs[r - 1][c - 1] = v

dp = [[[0] * (C + 1) for _ in range(R + 1)] for _ in range(4)]
for i in range(R):
    for j in range(C):
        for k in range(2, -1, -1):
            dp[k + 1][i][j] = max(dp[k + 1][i][j], dp[k][i][j] + xs[i][j])
        for k in range(4):
            dp[k][i][j + 1] = max(dp[k][i][j + 1], dp[k][i][j])
            dp[0][i + 1][j] = max(dp[0][i + 1][j], dp[k][i][j])
ans = 0
for k in range(4):
    ans = max(ans, dp[k][R - 1][C - 1])
print(ans)
### BUGGY CODE ###

import sys
input=sys.stdin.readline
from collections import defaultdict
from heapq import heappush, heappop,heappushpop,heapify
n,m = map(int, input().split())
link = defaultdict(list)
chg=10**8
for _ in range(m):
    p,q,c=map(int, input().split())
    link[p].append([p+chg*c,1])
    link[p+chg*c].append([p,1])

    link[q+chg*c].append([p+chg*c,0])
    link[p+chg*c].append([q+chg*c,0])

    link[q+chg*c].append([q,1])
    link[q].append([q+chg*c,1])

def dks(g,start):
    INF=float('inf')
    visited = defaultdict(int)
    hq = []
    heappush(hq, (0,start))
    cost = defaultdict(lambda: float("inf"))
    while hq:
        shortest, i = heappop(hq)
        if visited[i] != 0:
            continue
        visited[i] = 1
        cost[i] = shortest
        for j, t in g[i]:
            if visited[j] != 0:
                continue
            heappush(hq, (shortest + t, j))
    return cost
cost=dks(link,1)

ans=cost[n]
if ans == float("inf"):
    print(-1)
else:
    print(ans//2)

### FIXED CODE ###

import sys
input=sys.stdin.readline
from collections import defaultdict
from heapq import heappush, heappop,heappushpop,heapify
n,m = map(int, input().split())
link = defaultdict(list)
chg=10**8
for _ in range(m):
    p,q,c=map(int, input().split())
    link[p].append([p+chg*c,1])
    link[p+chg*c].append([p,1])

    link[q+chg*c].append([p+chg*c,0])
    link[p+chg*c].append([q+chg*c,0])

    link[q+chg*c].append([q,1])
    link[q].append([q+chg*c,1])

def dks(g,start):
    INF=float('inf')
    visited = set()
    hq = []
    heappush(hq, (0,start))
    while hq:
        shortest, i = heappop(hq)
        if i in visited:
            continue
        visited.add(i)
        for j, t in g[i]:
            if j in visited:
                continue
            if j==n:
                return (shortest+t)//2
            heappush(hq, (shortest + t, j))
    return -1
ans=dks(link,1)
print(ans)
### BUGGY CODE ###

import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    A = [int(x) for x in input().split()]

    A.sort()

    B = [False] * (max(A) + 1)

    ans = 0
    for i, a in enumerate(A):
        if B[a]:
            continue
        for aa in range(a, max(A) + 1, a):
            B[aa] = True

        if i != len(A) - 1 and A[i] == A[i + 1]:
            continue

        ans += 1

    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
import collections

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    aset = list(set(A))
    aset.sort()

    ans = [0] * (10 ** 6 + 1)

    for a in aset:
        for i in range(2, 10 ** 6 + 1):
            if a * i > 10 ** 6:
                break
            ans[a * i] += 1

    res = 0
    c = collections.Counter(A)
    for a in A:
        if ans[a] == 0 and c[a] == 1:
            res += 1

    print(res)



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

n, m = map(int, input().split())
a = list(int(input()) for _ in range(m))

dp = [0] * (n+1)
dp[0] = 1

if 1 in a:
    dp[1] = 0
else:
    dp[1] = 1

for i in range(2, n+1):
    if i in a:
        continue
    dp[i] = dp[i-1] + dp[i - 2]
    dp[i] %= 1000000007

print(dp[n])




### FIXED CODE ###

n, m = map(int, input().split())
a = set([int(input()) for _ in range(m)])

dp = [0] * (n+1)
dp[0] = 1

if 1 in a:
    dp[1] = 0
else:
    dp[1] = 1

for i in range(2, n+1):
    if i in a:
        continue
    dp[i] = dp[i-1] + dp[i - 2]
    dp[i] %= 1000000007

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

N = int(input())

dic = {}

for i in range(N):
    S = input()
    
    if (S in dic) == False:
        dic[S] = 1
    else:
        dic[S] += 1
        
keys = []
for key , value in dic.items():
    if value == max(dic.values()):
        keys.append(key)
k = keys.sort()
for i in keys:
    print(i)

### FIXED CODE ###

N = int(input())

dic = {}

for i in range(N):
    S = input()
    
    if (S in dic) == False:
        dic[S] = 1
    else:
        dic[S] += 1
        
keys = []
maxv = max(dic.values())
for key , value in dic.items():
    if value == maxv:
        keys.append(key)
k = keys.sort()
for i in keys:
    print(i)
### BUGGY CODE ###

n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
a.insert(0,0)
b.insert(0,0)

sum_a = [0]
for i in range(1,len(a)):
    sum_a.append(sum_a[i-1] + a[i])
    if sum_a[i] > k:
        break

sum_b = [0]
for i in range(1,len(b)):
    sum_b.append(sum_b[i-1] + b[i])
    if sum_b[i] > k:
        break

ans = 0
for i in range(len(sum_a)):
    if sum_a[i] > k:
        break
    for j in range(len(sum_b)-1,-1,-1):
        if sum_a[i] + sum_b[j] <= k:
            ans = max(ans, i+j)
            break
print(ans)



### FIXED CODE ###

n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
a.insert(0,0)
b.insert(0,0)

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

sum_b = [0]
for i in range(1,m+1):
    sum_b.append(sum_b[i-1] + b[i])

ans = 0
for i in range(n+1):
    if sum_a[i] > k:
        break
    for j in range(m,-1,-1):
        if sum_a[i] + sum_b[j] <= k:
            ans = max(ans, i+j)
            m = j
            break
print(ans)
### BUGGY CODE ###

def quick_sort(list):
    stand=list[0]
    over=[]
    same=[]
    under=[]
    for i in list:
        if(i>stand):
            over.append(i)
        elif(i<stand):
            under.append(i)
        else:
            same.append(i)
    if(len(over)>1):
        over=quick_sort(over)
    else:
        pass
    if(len(under)>1):
        under=quick_sort(under)
    else:
        pass

    return over+same+under

N,K=map(int,input().split())
p=list(map(int,input().split()))
ans=sum(p[0:K])
for i in range(len(p)-K+1):
    if(ans<sum(p[i:i+K])):
        ans=sum(p[i:i+K])
    else:
        pass
print((ans+K)/2)

### FIXED CODE ###

N,K=map(int,input().split())
p=list(map(int,input().split()))
ans=sum(p[0:K])
all_sum=[sum(p[0:K])]
for i in range(len(p)-K):
    ans=ans+p[i+K]-p[i]
    all_sum.append(ans)
ans=max(all_sum)
print((ans+K)/2)
### BUGGY CODE ###

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

# len 取り得る最大の長さは N / 2

for i in range(N//2, 0, -1):
  for j in range(0, N-2*i+1):
    left = S[j:j+i]
    for k in range(j+i, N-i+1):
      right = S[k:k+i]
      
      # print(i, j, k)
      # print("left : ", left)
      # print("right: ", right)
      
      if left == right:
        print(len(left))
        exit()
        
print(0)

### FIXED CODE ###

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


r = 0
ans = 0
for l in range(N):

    while True:
        # print(S.rfind(S[l:r+1]), S[l:r+1], l, r)
        
        if S.rfind(S[l:r+1]) >= r+1:
            r += 1
            ans = max(ans, r-l)
        else:
            break

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

n, k = [int(x) for x in input().split()]
h = [int(x) for x in input().split()]

def abs(x):
    if x >= 0:
        return x
    return -x

c = [0]
c.append(abs(h[1] - h[0]))
for i in range(2, n):
    cmin = None
    for cur in range(i-1, i-1-k, -1):
        if cur < 0:
            break
        val = abs(h[i] - h[cur]) + c[cur]
        if cmin is None or val < cmin:
            cmin = val
    c.append(cmin)

print(c[-1])


### FIXED CODE ###

def main():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    a = [0] * n
    a[0] = 0
    for i in range(1, n):
        a[i] = min([a[j] + abs(h[i] - h[j]) for j in range(max(0, i - k), i)])
    print(a[-1])
 
if __name__ == '__main__':
    main()
### BUGGY CODE ###

from collections import defaultdict
N, M = map(int, input().split())
dep = []
arr = []
ans = "IMPOSSIBLE"

for i in range(M):
  a,b = map(int ,input().split())
  if a == 1: dep.append(b-1)
  if b == N: arr.append(a-1)
 
for i in (arr):
  if i in dep:
    ans = "POSSIBLE"
    break
print(ans)

### FIXED CODE ###

from collections import defaultdict
N, M = map(int, input().split())

shima = []
ans = "IMPOSSIBLE"

for i in range(M):
  a,b = map(int ,input().split())
  if a == 1: shima.append(b-1)
  if b == N: shima.append(a-1)
    
shima.sort()
for s,t in zip(shima[:-1],shima[1:]):
  if s == t:
    ans = "POSSIBLE"
    break
 
print(ans)
### BUGGY CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for _ in range(M)]

R=[]
for i in BC:
    R.extend([i[1]]*i[0])

A=sorted(A+R)
print(sum(A[len(R):]))



### FIXED CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for _ in range(M)]

A.sort(reverse=True)
BC.sort(key=lambda x:x[1],reverse=True)

R=[]
n=0
for i in range(M):
    R.extend([BC[i][1]]*BC[i][0])
    n = n + BC[i][0]
    if n >= N:
        break

R=sorted(A+R, reverse=True)[:N]
print(sum(R))
### BUGGY CODE ###

#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr

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

    ans = 0
    for i in a:
        arr = factorization(i)
        for j in range(len(arr)):
            if arr[j][0] == 2:
                ans += arr[j][1]
    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

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

    ans = 0
    for i in range(N):
        while a[i] % 2 == 0:
            a[i] = a[i] // 2
            ans += 1
    print(ans)

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

import fractions
#A=int(input())
#A=list(map(int,(input().split())))
A,B=list(map(int,(input().split())))
C=fractions.gcd(A,B)
lis=[]
waru=2
while (C!=1):
	
	if C%waru==0:
		lis.append(waru)
		while(C%waru==0):
			C/=waru
	waru+=1
print(len(lis)+1)

### FIXED CODE ###

import fractions
#A=int(input())
#A=list(map(int,(input().split())))
A,B=list(map(int,(input().split())))
C=fractions.gcd(A,B)
lis=[]
waru=2
while (C!=1 and waru<=C**0.5+10):
	
	if C%waru==0:
		lis.append(waru)
		while(C%waru==0):
			C/=waru
	waru+=1
if C!=1:lis.append(waru)
print(len(lis)+1)
### BUGGY CODE ###

N = int(input())

result = 1
for n in map(int, input().split()):
    result *= n

if result > 10 ** 18:
    result = -1
print(result)

### FIXED CODE ###

import math
import sys
from collections import *
from itertools import *

N = int(input())

OVERFLOW = 10 ** 18

seq = list(map(int, input().split()))
seq.sort()
if seq[0] == 0:
    print(0)
    sys.exit(0)

result = 1
for n in reversed(seq):
    result *= n
    if result > OVERFLOW:
        print(-1)
        sys.exit(0)
print(result)