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

s = input()
t = input()
ls = len(s)
lt = len(t)
DP = [[''] * (lt+1) for i in range(ls+1)]
for i in range(1, ls+1):
    for j in range(1, lt+1):
        if s[i-1] == t[j-1]:
            if (len(DP[i-1][j-1]) + 1 >= len(DP[i][j-1])) and (len(DP[i-1][j-1]) + 1 >= len(DP[i-1][j])):
                DP[i][j] = DP[i-1][j-1] + s[i-1]
                flag = False
            else:
                if (len(DP[i-1][j]) >= len(DP[i][j-1])) and (len(DP[i-1][j]) >= len(DP[i][j])):
                    DP[i][j] = DP[i-1][j]
                elif (len(DP[i-1][j]) <= len(DP[i][j-1])) and (len(DP[i][j-1]) >= len(DP[i][j])):
                    DP[i][j] = DP[i][j-1]

        else:
            if (len(DP[i - 1][j]) >= len(DP[i][j - 1])) and (len(DP[i - 1][j]) >= len(DP[i][j])):
                DP[i][j] = DP[i - 1][j]
            elif (len(DP[i - 1][j]) <= len(DP[i][j - 1])) and (len(DP[i][j - 1]) >= len(DP[i][j])):
                DP[i][j] = DP[i][j - 1]

print(DP[ls][lt])



### FIXED CODE ###

from collections import deque

s = input()
t = input()
ls = len(s)
lt = len(t)
DP_len = [[0] * (lt + 1) for i in range(ls + 1)]
Prev =[[0] * (lt + 1) for i in range(ls + 1)]
for i in range(1, ls + 1):
    for j in range(1, lt + 1):
        if s[i - 1] == t[j - 1]:
            if max(DP_len[i - 1][j - 1] + 1, DP_len[i][j - 1], DP_len[i - 1][j]) == DP_len[i-1][j-1] + 1:
                DP_len[i][j] = DP_len[i-1][j-1] + 1
                Prev[i][j] = (i-1, j-1)
            else:
                if DP_len[i][j - 1] >= DP_len[i - 1][j]:
                    DP_len[i][j] = DP_len[i][j - 1]
                    Prev[i][j] = (i, j - 1)
                else:
                    DP_len[i][j] = DP_len[i - 1][j]
                    Prev[i][j] = (i - 1, j)

        else:
            if DP_len[i][j - 1] >= DP_len[i - 1][j]:
                DP_len[i][j] = DP_len[i][j - 1]
                Prev[i][j] = (i, j-1)
            else:
                DP_len[i][j] = DP_len[i - 1][j]
                Prev[i][j] = (i - 1, j)

x = ls
y = lt
ans = ''
while True:
    if x == 0 or y == 0:
        break
    nx, ny = Prev[x][y]
    if (nx != x) and (ny != y):
        ans = s[x-1] + ans
    x = nx
    y = ny
print(ans)
### BUGGY CODE ###

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

s = []
for i in range(n):
  s.append(abs(sum(a[:i])*2-sum(a)))

print(min(s))

### FIXED CODE ###

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

x = n//2
if sum(a)/2 == sum(a[:(n//2)]):
  print(0)
elif sum(a)/2 >= sum(a[:(n//2)]):
  while sum(a)/2 >= sum(a[:x]):
    x += 1  
  print(min(abs(2*sum(a[:x])-sum(a)), abs(2*sum(a[:x-1])-sum(a))))
else:
  while sum(a)/2 <= sum(a[:x]):
    x -= 1
  print(min(abs(2*sum(a[:x])-sum(a)), abs(2*sum(a[:x+1])-sum(a))))
### BUGGY CODE ###

import bisect

def solve():
    N = int(input())
    S = list(input())
    Q = int(input())
    set_dic = {}

    for i, s in enumerate(S):
        if s not in set_dic.keys():
            set_dic[s] = [i+1]
        else:
            bisect.insort_left(set_dic[s], i+1)

    anslist = []

    for _ in range(Q):
        query1, query2, query3 = input().split()
        if query1 == "1":
            i = int(query2)
            c = query3
            cap = S[i-1]
            if cap == c:
                continue
            set_dic[cap].remove(i)
            if c not in set_dic.keys():
                set_dic[c] = [i]
            else:
                bisect.insort_left(set_dic[c], i)
            S[i-1] = c
        else:
            l = int(query2)
            r = int(query3)
            ansset = set()
            ans = 0
            for eachlist in set_dic.values():
                li = bisect.bisect_left(eachlist, l)
                ri = bisect.bisect_right(eachlist, r)
                if li != ri:
                    ans += 1
            anslist.append(ans)

    for i in anslist:
        print(i)

if __name__ == '__main__':
    solve()

### FIXED CODE ###

import bisect
import sys
input = sys.stdin.readline

def solve():
    N = int(input())
    S = list(input())
    Q = int(input())
    set_dic = {}

    for i, s in enumerate(S):
        if s not in set_dic:
            set_dic[s] = [i+1]
        else:
            bisect.insort_left(set_dic[s], i+1)

    anslist = []

    for _ in range(Q):
        query1, query2, query3 = input().split()
        if query1 == "1":
            i = int(query2)
            c = query3
            cap = S[i-1]
            if cap == c:
                continue
            set_dic[cap].remove(i)
            if c not in set_dic:
                set_dic[c] = [i]
            else:
                bisect.insort_left(set_dic[c], i)
            S[i-1] = c
        else:
            l = int(query2)
            r = int(query3)
            ansset = set()
            ans = 0
            for eachlist in set_dic.values():
                li = bisect.bisect_left(eachlist, l)
                ri = bisect.bisect_right(eachlist, r)
                if li != ri:
                    ans += 1
            anslist.append(ans)

    for i in anslist:
        print(i)

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

import sys
input = sys.stdin.readline

def main():
    N,M = map(int,input().split())
    A = list(map(int, input().split()))
    X = [list(map(int,input().split())) for _ in range(M)]
    total = sum(A)
    X.sort(key=lambda x:x[1], reverse = True)

    for i in range(M):
        A.sort()
        for j in range(X[i][0]):
            min = A.pop(j)
            if min < X[i][1]:
                A.insert(0, X[i][1])
                total += (X[i][1] - min)
            else:
                A.insert(0, min)
                break

    print(total)

if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline
import heapq

def main():
    N,M = map(int,input().split())
    q = list(map(int, input().split()))
    X = [list(map(int,input().split())) for _ in range(M)]
    X.sort(key=lambda x:-x[1])
    total = sum(q)
    heapq.heapify(q)

    for i in range(M):
        for j in range(X[i][0]):
            tmp = heapq.heappushpop(q, X[i][1])
            if tmp < X[i][1]:
                total += (X[i][1] - tmp)
            else:
                break

    print(total)

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

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

#logging.debug("デバッグスタート") #
l = [[] for i in range(n)]#期待値
m = [[] for i in range(n - k + 1)]  #k個の合計

for i in range(n):
    for j in range(p[i]):
        j += 1
        l[i].append(j/ p[i])
#        logging.debug("l[i]={},i={},j={}".format(l[i],i,j))
    l[i] = sum(l[i])

#logging.debug("l = {}".format(l))#
m[0] = sum(l[0:k])
ans = m[0]

for i in range(1, n - k + 1):
    #logging.debug("m[i-1] = {} ,l[i-1] = {} ,l[i+k] = {}".format(m[i - 1], l[i - 1], l[i + k - 1]))  #
    m[i] = m[i - 1] - l[i - 1] + l[i + k - 1]
    if m[i] > ans:
        ans = m[i]

#logging.debug(m)#
print(ans)

### FIXED CODE ###

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

#logging.debug("デバッグスタート") #
l = [[] for i in range(n)]#期待値
m = [[] for i in range(n - k + 1)]  #k個の合計

for i in range(n):
    l[i] = (1 + p[i]) / 2

#logging.debug("l = {}".format(l))#
m[0] = sum(l[0:k])
ans = m[0]

for i in range(1, n - k + 1):
    #logging.debug("m[i-1] = {} ,l[i-1] = {} ,l[i+k] = {}".format(m[i - 1], l[i - 1], l[i + k - 1]))  #
    m[i] = m[i - 1] - l[i - 1] + l[i + k - 1]
    if m[i] > ans:
        ans = m[i]

#logging.debug(m)#
print(ans)
### BUGGY CODE ###

# coding: utf-8
from collections import deque
def bfs(maze, visited, sy, sx, gy, gx):
    queue = deque([[sy, sx]])
    count = 0
    while queue:
        #ここでforループを回している
        for _ in range(len(queue)):
            coord = queue.popleft()
            visited[coord[0]][coord[1]] = 1
            if coord == [gy, gx]:
                return count
            for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
                next_coord = [coord[0]+j, coord[1]+k]
                if next_coord[0] < 0 or next_coord[0] > H-1 or next_coord[1] < 0 or next_coord[1] > W-1:
                    continue
                if maze[next_coord[0]][next_coord[1]] == "." and \
                   visited[next_coord[0]][next_coord[1]] != 1:
                    queue.append(next_coord)
        count += 1


import sys
sys.setrecursionlimit(10**8)
H, W = map(int, input().split())
maze = []
for i in range(H):
    tmp = list(input())
    # tmp = input()
    maze.append(tmp[:])
# print(*maze, sep="\n")
# exit()
ans = -1
for sx in range(H):
    for sy in range(W):
        for ex in range(H):
            for ey in range(W):
                if maze[sx][sy] == "#" or maze[ex][ey] == "#":
                    continue
                if sx == ex and sy == ey:
                    continue
                # maze[ex][ey] = "g"
                top = [-1]
                visited = [[-1 for _ in range(W)] for _ in range(H)]
                # dfs(sx, sy, 0)
                tmp = bfs(maze, visited, sx, sy, ex, ey)
                ans = max(ans, tmp)
print(ans)

### FIXED CODE ###

# coding: utf-8
from collections import deque
H, W = map(int, input().split())
INF = -1
maze = []
for i in range(H):
    tmp = list(input())
    maze.append(tmp[:])

def bfs(sx, sy):
    visited = [[INF for _ in range(W)] for _ in range(H)]
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]
    q = deque()
    q.append([sx, sy])
    visited[sx][sy] = 0
    while q:
        p = q.popleft()
        for i in range(4):
            nx = p[0] + dx[i]
            ny = p[1] + dy[i]
            if 0 <= nx < H and 0 <= ny < W:
                if maze[nx][ny] != "#" and visited[nx][ny] == INF:
                    q.append([nx, ny])
                    visited[nx][ny] = visited[p[0]][p[1]] + 1
        dist = -1
        for i in range(H):
            dist = max(dist, max(visited[i]))
    return dist
ans = -1
for i in range(H):
    for j in range(W):
        x, y = i, j
        if maze[x][y] == "#":
            continue
        ans = max(ans, bfs(x, y))
print(ans)
### BUGGY CODE ###

n,m=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(m)]
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
      
      
uf = UnionFind(n+1)
for i in range(m):
  uf.union(ab[i][0], ab[i][1])
ans=0
for i in range(uf.group_count()):
  if ans < len(uf.members(i)):
    ans = len(uf.members(i))
print(ans)

### FIXED CODE ###

n,m=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(m)]
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
      
      
uf = UnionFind(n+1)
for i in range(m):
  if uf.same(ab[i][0], ab[i][1]) == False:
    uf.union(ab[i][0], ab[i][1])
ans=0
for i in range(1,n+1):
  if ans <uf.size(i):
    ans=uf.size(i)
print(ans)
### BUGGY CODE ###

n,s=int(input()),input()

cnt=0
flag1=[]
ans=[]
for i in range(n-2):
    flag2=[]
    if s[i] in flag1:continue
    flag1.append(s[i])
    for j in range(i+1,n-1):
        if s[i]!=s[j] and s[j] in flag2:continue
        flag2.append(s[j])
        for k in range(j+1,n):
            ans.append(s[i]+s[j]+s[k])
#print(ans,flag1,flag2)
print(len(set(ans)))

### FIXED CODE ###

n=int(input())
s=input()
#000~999からいくつ作れるか試す
num='0123456789'
ans=0
#候補の暗証番号を生成する
for first_num in num:
    for second_num in num:
        for third_num in num:
            temp_lock=first_num+second_num+third_num
            temp_cnt=0
            for i in s:
                if temp_cnt==0 and i==temp_lock[0]:
                    temp_cnt=1
                elif temp_cnt==1 and i==temp_lock[1]:
                    temp_cnt=2
                elif temp_cnt==2 and i==temp_lock[2]:
                    ans+=1
                    break
print(ans)
### BUGGY CODE ###

s=input()
n=len(s)
mod=10**9+7
dp=[[0 for i in range(13)] for i in range(n)]
if s[0]=="?":
  for i in range(10):
    dp[0][i]=1
else:
  dp[0][int(s[0])]=1
for i in range(1,n):
  if s[i]=="?":
    for j in range(13):
      for k in range(10):
        dp[i][(10*j+k)%13]+=dp[i-1][j]
        dp[i][(10*j+k)%13]%=mod
  else:
    for j in range(13):
      dp[i][(10*j+int(s[i]))%13]+=dp[i-1][j]
      dp[i][(10*j+int(s[i]))%13]%=mod
print(dp[n-1][5])

### FIXED CODE ###

s=input()
n=len(s)
mod=10**9+7
dp=[[0 for i in range(13)] for i in range(n)]
if s[0]=="?":
  for i in range(10):
    dp[0][i]=1
else:
  dp[0][int(s[0])]=1
for i in range(1,n):
  if s[i]=="?":
    for j in range(13):
      for k in range(10):
        dp[i][(10*j+k)%13]+=dp[i-1][j]
  else:
    for j in range(13):
      dp[i][(10*j+int(s[i]))%13]+=dp[i-1][j]
  for j in range(13):
    dp[i][j]%=mod
print(dp[n-1][5])
### BUGGY CODE ###

INF = -1000000000000001

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

a = int(n/2)

dpa = [[INF]*(a+1) for i in range(n+1)]

dpa[0][0] = 0
for i in range(1,n+1):
	dpa[i][0] = 0
	if i % 2 == 0:
		j = int(i / 2)
		dpa[i][j] = max(dpa[i-2][j-1]+l[i-1],dpa[i-1][j])
#		print(i,j,dpa[i][j])
	elif i == 1:
		dpa[1][1] = l[0]
	else:
		j = int((i-1)/2)
		dpa[i][j] = max(dpa[i-2][j-1]+l[i-1],dpa[i-1][j])
#		print(i,j,dpa[i][j])
		if (i != n):
			j += 1
#			print(i,j,dpa[i][j])
#			print("   ",i-2,j-1,dpa[i-2][j-1],"")
			dpa[i][j] = dpa[i-2][j-1]+l[i-1]

#print(dpa)
print(dpa[n][a])


### FIXED CODE ###

from collections import defaultdict
INF = -1000000000000001

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

a = int(n/2)

dpa = defaultdict(lambda: -INF)
#dpa = [[0 for j in range(a+1)] for i in range(n+1)]

dpa[(0,0)] = 0
dpa[(1,0)] = 0
dpa[(1,1)] = l[0]
j = 1
for i in range(2,n+1):
	if i == j*2:
		dpa[(i,j)] = max(dpa[(i-2,j-1)]+l[i-1],dpa[(i-1,j)])
#		print(i,j,dpa[(i,j)])
	else:
		dpa[(i,j)] = max(dpa[(i-2,j-1)]+l[i-1],dpa[(i-1,j)])
#		print(i,j,dpa[(i,j)])
		if (i != n):
			j += 1
#			print(i,j,dpa[(i,j)])
#			print("   ",i-2,j-1,dpa[(i-2,j-1)],"")
			dpa[(i,j)] = dpa[(i-2,j-1)]+l[i-1]

#print(dpa)
print(dpa[n,a])
### BUGGY CODE ###

from collections import deque

h,w = map(int,input().split())
field = [ list(input()) for _ in range(h) ]

d = [ [float("inf")]*w for _ in range(h) ]
q = deque()

for j in range(h):
    for i in range(w):
        a = field[j][i]
        if a=="#":
            q.append([j,i])
            d[j][i] = 0
        else:
            pass

def bfs(d):
    m = 0
    while q:
        y,x = q.popleft()
        for j,i in ([1,0],[0,-1],[-1,0],[0,1]):
            ny = y + j
            nx = x + i
            if ny==-1 or nx==-1 or ny==h or nx==w:
                pass
            elif field[ny][nx]=="#":
                pass
            elif d[ny][nx]!=float("inf"):
                pass
            else:
                field[ny][nx] = "#"
                d[ny][nx] = d[y][x] + 1
                m = max(m,d[ny][nx])
                q.append([ny,nx])
    return m

m = bfs(d)
print(m)

### FIXED CODE ###

from collections import deque

h,w = map(int,input().split())
field = [ list(input()) for _ in range(h) ]

visited = [ [0]*w for _ in range(h) ]
q = deque()

for j in range(h):
    for i in range(w):
        a = field[j][i]
        if a=="#":
            q.append([j,i,0])
            visited[j][i] = 1
        else:
            pass

m = 0
while q:
    y,x,d = q.popleft()
    for j,i in ([1,0],[0,-1],[-1,0],[0,1]):
        ny = y + j
        nx = x + i
        if ny==-1 or nx==-1 or ny==h or nx==w:
            pass
        elif visited[ny][nx]==0:
            visited[ny][nx] = 1
            q.append([ny,nx,d+1])
            m = max(m,d+1)   
print(m)
### BUGGY CODE ###

import copy

N = int(input())
sequences = [int(input()) for _ in range(N)]

for i in range(N):
        tmp = copy.copy(sequences)
        tmp.pop(i)
        tmp_set = set(tmp)
        print(max(tmp_set))

### FIXED CODE ###

import copy
import numpy as np
N = int(input())
sequences = [int(input()) for _ in range(N)]
np_sequences = np.array(sequences)
max_index = np_sequences.argmax()
for i in range(N):
        if i != max_index:
            print(sequences[max_index])
        else:
            tmp = copy.copy(sequences)
            tmp.pop(i)
            tmp_set = set(tmp)
            print(max(tmp_set))
### BUGGY CODE ###

N,M = (int(i) for i in input().split())
e = [[int(i) for i in input().split()] for i in range(M)]
hoge = set()

zenbu = {int(i + 1) for i in range(N)}

for i in e:
    konkaino = {int(i) for i in range(i[0],i[1] + 1)}
    zenbu = zenbu & konkaino


print(len(zenbu))

### FIXED CODE ###

N,M = (int(i) for i in input().split())
e = [[int(i) for i in input().split()] for i in range(M)]

right = N
left = 0

for i in e:
    if left < i[0]:
        left = i[0]
    if right > i[1]:
        right = i[1]
if right >= left:
    print(right - left + 1)
else:
    print("0")
### BUGGY CODE ###

import numpy as np
n = int(input())
a = np.array([], dtype=np.int64)
a_ = list(map(int, input().split()))
for i in a_:
    a = np.append(a, i)
m = 10**9+7
ans = 0
for k in range(0, 61):
    b = (a>>k) & 1
    res = np.count_nonzero(b)
    ans += res*(n-res)*2**k
print(ans%m)

### FIXED CODE ###

import numpy as np
n = int(input())
a = np.array([int(i) for i in input().split()] , dtype=np.int64)
m = 10**9+7
ans = 0
for k in range(60):
    b = (a>>k) & 1
    res = np.count_nonzero(b)
    ans += res*(n-res)*2**k
print(ans%m)
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
sum = 0
INF = 10 ** 9 + 7
for m in range(N):
  for n in range(m+1,N):
    sum = (sum + A[m] * A[n]) % INF
print(sum)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
INF = 10 ** 9 + 7
s = A[0] * A[1] % INF
tmp = A[0]
for n in range(2,N):
  tmp += A[n-1] % INF
  s = (s + A[n] * tmp) % INF
print(s)
### BUGGY CODE ###

N = input()
inp = input()
listA = inp.split(' ')
count = 0
for moji in listA:
    youso = listA.count(moji)
    if youso == 1:
        count += 1
    else:
        print('NO')
        break
if count == len(listA):
    print('YES')

### FIXED CODE ###

N = int(input())
inputA = input()
listA = inputA.split(' ')
listA.sort()
output = 'YES'
for i in range (len(listA) - 1):
    if listA[i] == listA[i + 1]:
        output = 'NO'
print(output)
### BUGGY CODE ###

N,M=map(int,input().split())
ans=0
while True:
    if M>=2 and N>=1:
        ans+=1
        N-=1
        M-=2
    elif M>=4:
        ans+=1
        M-=4
    else:
        break
print(ans)


### FIXED CODE ###

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

if M>=2*N:
    ans+=N
    M-=2*N
    ans+=M//4
    print(ans)
    exit()
else:
    ans+=M//2
    print(ans)
    exit()
### BUGGY CODE ###

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

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

for i in range(N):
  X = 0
  for j in range(N):
    if j % 2:
       X += A[(i+j)%N]
  print(S-2*X, end=" ")
print()


### FIXED CODE ###

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

S = 0
for i in range(N):
  S += A[i]
X = S
for i in range(N):
  if i%2:
    X -= 2*A[i]
print(X, end=" ")
for i in range(1,N):
    X = 2*A[i-1]-X
    print(X, end=" ")
print()
### BUGGY CODE ###

#!/usr/bin/env python3
import sys
sys.setrecursionlimit(1000000)
from collections import deque

H, W = map(int, input().split())
#配列の入力
data = [list(input()) for _ in range(H)]

memo = [[-1 for _ in range(W)]for _ in range(H)]
que = deque()

for h in range(H):
    for w in range(W):
        if data[h][w] == '#':
            memo[h][w] = 0
            que.append((h, w))

offset = ((-1, 0), (1, 0), (0, -1), (0, 1))
while que:
    now_h, now_w = que.popleft()
    for nh, nw in offset:
        if now_h+nh < 0 or H-1 < now_h+nh or now_w+nw < 0 or W-1 < now_w+nw:
            continue

        if memo[now_h+nh][now_w+nw] >= 0:
            continue

        memo[now_h+nh][now_w+nw] = memo[now_h][now_w]+1
        que.append((now_h+nh,now_w+nw))


ans = -1
for h in range(H):
    ans = max(ans, max(memo[h]))
print(ans)


### FIXED CODE ###


import sys
sys.setrecursionlimit(1000000)
from collections import deque

H, W = map(int, input().split())
#配列の入力
data = [list(input()) for _ in range(H)]

memo = [[-1 for _ in range(W)]for _ in range(H)]
que = deque()

for h in range(H):
    for w in range(W):
        if data[h][w] == '#':
            memo[h][w] = 0
            que.append((h, w))

offset = ((-1, 0), (1, 0), (0, -1), (0, 1))
while que:
    now_h, now_w = que.popleft()
    for nh, nw in offset:
        if now_h+nh < 0 or H-1 < now_h+nh or now_w+nw < 0 or W-1 < now_w+nw:
            continue

        if memo[now_h+nh][now_w+nw] >= 0:
            continue

        memo[now_h+nh][now_w+nw] = memo[now_h][now_w]+1
        que.append((now_h+nh,now_w+nw))


ans = -1
for h in range(H):
    ans = max(ans, max(memo[h]))
print(ans)
### BUGGY CODE ###

def main():
    n = int(input())
    A = list(map(int, input().split()))
    limit = 10 ** 18
    ans = 1
    for i in range(n):
        ans *= A[i]
        #print(ans)

    if ans > limit:
        print(-1)
    else:
        print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    n = int(input())
    A = list(map(int, input().split()))
    A.sort(reverse=True)
    limit = 10 ** 18
    #print(A)

    if A[-1] == 0:
        print(0)
    elif A[0] > limit:
        print(-1)
    else:
        ans = A[0]
        for i in range(1, n):
            ans *= A[i]
            if ans > limit:
                print(-1)
                exit()

        print(ans)


if __name__ == "__main__":
    main()