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

n = input()
n = int(n)

li = [int(input()) for i in range(n)]

for j in range(n):
  buf = li.pop(j)
  print(max(li))
  li.insert(j,buf)


### FIXED CODE ###

n = input()
n = int(n)

li = [int(input()) for i in range(n)]
m = max(li)
m2 = sorted(li)[-2]

for j in range(n):
  if m == li[j]:
    print(m2)
  else:
    print(m)
### BUGGY CODE ###

n=int(input())
A=list(map(int,input().split()))
A.sort()
md=0
for i in range(n-1):
    for j in range(i+1,n):
        if A[j]-A[i]<=2:
            md = max(j-i,md)
print(md+1)



### FIXED CODE ###

import collections

n=int(input())
A=list(map(int,input().split()))
A.sort()
md=0
j=0
for i in range(n-1):
    while j<n:
        if A[j]-A[i]<=2:
            md = max(j-i,md)
            j+=1
        else:
            break
print(md+1)
### BUGGY CODE ###

import collections
from functools import reduce

S = input()
Q = int(input())

deque = collections.deque(S)

is_reverse = False
for _ in range(Q):
    query = input().split()
    if query[0] == '1':
        is_reverse = not is_reverse
    else:
        if (query[1] == '1' and not is_reverse) or (query[1] =='2' and is_reverse):
            deque.appendleft(query[2])
        else:
            deque.append(query[2])
if is_reverse:
    deque.reverse()
print(reduce(lambda x, y: x+y, list(deque)))


### FIXED CODE ###

import collections
from functools import reduce

S = input()
Q = int(input())

deque = collections.deque(S)

is_reverse = False
for _ in range(Q):
    query = input().split()
    if query[0] == '1':
        is_reverse = not is_reverse
    else:
        if (query[1] == '1' and not is_reverse) or (query[1] =='2' and is_reverse):
            deque.appendleft(query[2])
        else:
            deque.append(query[2])
if is_reverse:
    deque.reverse()

res = list(deque)

print("".join(res))
### BUGGY CODE ###

from collections import defaultdict
def inpl(): return [int(i) for i in input().split()]

H = defaultdict(lambda: [])
N = int(input())
A = inpl()
k = 2**30
ans = 0
for j in range(30,0,-1):
    k = 2**j
    t = []
    H = defaultdict(lambda: [])
    for i in A:
        if H[k-i]:
            t.append(H[k-i].pop())
            t.append(i)
            ans += 1
        else:
            H[i].append(i)
    for p in t:
        A.remove(p)
print(ans)

### FIXED CODE ###

import bisect
from collections import defaultdict
def inpl(): return [int(i) for i in input().split()]
H = defaultdict(lambda: [])
Ad = defaultdict(lambda: 0)
N = int(input())
A = inpl()
for i in A:
    Ad[i] += 1
A = list(set(A))
A.sort()
ans = 0
for j in range(30,0,-1):
    k = 2**j
    H = defaultdict(lambda: [])
    ml = bisect.bisect_left(A, k) 
    for i in A[:ml]:
        if 2*i == k:
            ans += Ad[i]//2
            del Ad[i]
            continue
        if H[k-i]:
            m = min(Ad[k-i], Ad[i])
            Ad[k-i] -= m
            del Ad[i]
            ans += m
        else:
            H[i] = j
print(ans)
### BUGGY CODE ###

s=str(input())
n=len(s)
for i in range(n):
  if s[i]=="?":
    s=s[:i]+"D"+s[i+1:]
print(s)

### FIXED CODE ###

s=str(input())
print(s.replace('?', 'D'))
### BUGGY CODE ###

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
import random

N = int(input())
A_s = list(map(int, input().split()))
pc = True
sc = True
M = {}
MAX = 0

for i,A in enumerate(A_s):
    for p in factorization(A):
        if p[0] == 1:
            continue
        if p[0] in M:
            # print()
            M[p[0]] += 1
            pc = False
        else:
            M[p[0]] = 1
        MAX = max(MAX, M[p[0]])
    if not pc and MAX <= i:
        break
else:
    sc = False

if pc:
    print('pairwise coprime')
elif sc:
    print('setwise coprime')
else:
    print('not coprime')

### FIXED CODE ###

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 make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

import itertools
import collections
def prime_factor_table(n):
    table = [0] * (n + 1)
    
    for i in range(2, n + 1):
        if table[i] == 0:
            for j in range(i + i, n + 1, i):
                table[j] = i
    
    return table

def prime_factor(n, prime_factor_table):
    prime_count = collections.Counter()
    
    while prime_factor_table[n] != 0:
        prime_count[prime_factor_table[n]] += 1
        n //= prime_factor_table[n]
    prime_count[n] += 1
    
    return prime_count

N = int(input())
A_s = list(map(int, input().split()))
# A_s = [int(i+1) for i in range(N)]
pc = True
sc = True
M = {}
MAX = 0
TABLE = prime_factor_table(10**6+1)

for i,A in enumerate(A_s):
    L = prime_factor(A, TABLE)
    for l in L.keys():
        if l == 1:
            continue
        if l in M:
            # print()
            M[l] += 1
            pc = False
        else:
            M[l] = 1
        MAX = max(MAX, M[l])
    if not pc and MAX <= i:
        break
else:
    sc = False

if pc:
    print('pairwise coprime')
elif sc:
    print('setwise coprime')
else:
    print('not coprime')
### BUGGY CODE ###

import queue
import copy

H,W = map(int,input().split())
S = [list(input()) for _ in range(H)]

def movable(S,px,py):
    if  0 <= px and px < H and 0 <= py and py < W:
        if S[px][py] == ".":
            return True
        else:
            return False
    else:
        return False

def bfs(S,sx,sy):
    S_dist = [[0 for _ in range(W)] for _ in range(H)]
    q = queue.Queue()
    q.put((sx,sy))
    vec = [(0,1),(0,-1),(1,0),(-1,0)]
    while not q.empty():
        p = q.get()
        S[p[0]][p[1]] = "#"
        for vx,vy in vec:
            if movable(S,p[0]+vx,p[1]+vy):
                S_dist[p[0]+vx][p[1]+vy] = S_dist[p[0]][p[1]]+1
                q.put((p[0]+vx,p[1]+vy))
    ret = 0
    for i in range(len(S_dist)):
        tmp_max = max(S_dist[i])
        ret = max(ret,tmp_max)
    return ret

ans = 0
for i in range(H*W):
    if S[i//W][i%W] == ".":
        S_ = copy.deepcopy(S)
        ans = max(ans,bfs(S_,i//W,i%W))
print(ans)


### FIXED CODE ###

import queue
import copy

H,W = map(int,input().split())
S = [list(input()) for _ in range(H)]
INF = H*W+1

def movable(S,S_dist,px,py):
    if  0 <= px and px < H and 0 <= py and py < W:
        if S_dist[px][py] == INF and S[px][py] == ".":
            return True
    return False

def bfs(S,sx,sy):
    S_dist = [[INF for _ in range(W)] for _ in range(H)]
    #Sを直接いじれば訪問済みかどうか管理できるがそれだと毎回Sをリセットする必要がある
    #S_distのみ書き込みにすればS_distはローカルだからリセットが不要
    S_dist[sx][sy] = 0
    q = queue.Queue()
    q.put((sx,sy))
    vec = [(0,1),(0,-1),(1,0),(-1,0)]
    ret = 0
    while not q.empty():
        p = q.get()
        ret = S_dist[p[0]][p[1]]
        for vx,vy in vec:
            if movable(S,S_dist,p[0]+vx,p[1]+vy):
                S_dist[p[0]+vx][p[1]+vy] = S_dist[p[0]][p[1]]+1
                q.put((p[0]+vx,p[1]+vy))
    return ret

ans = 0
for i in range(H*W):
    if S[i//W][i%W] == ".":
        ans = max(ans,bfs(S,i//W,i%W))
print(ans)
### BUGGY CODE ###

Q = int(input())
LR = []
max = 0

for i in range(Q):
  _input = input().split(' ')
  LR.append((int(_input[0]), int(_input[1])))
  if max < LR[i][1]:
    max = LR[i][1]

num = [True]*(max+1)
num[0] = num[1] = False
for i in range(2,int(max**0.5)+1):
  if num[i]:
    for j in range(i**2, max, i):
      num[j] = False

for i in range(Q):
  sum = 0
  if LR[i][0] % 2 == 0:
    for i in range(LR[i][0]+1, LR[i][1]+1, 2):
      if (num[i]) and (num[int((i+1)/2)]):
        sum = sum + 1
  else:
    for i in range(LR[i][0], LR[i][1]+1, 2):
      if (num[i]) and (num[int((i+1)/2)]):
        sum = sum + 1
  print(sum)

### FIXED CODE ###

num = [True]*100001
num[0] = num[1] = False
for i in range(2,317):
  if num[i]:
    for j in range(i**2, 100000, i):
      num[j] = False

c = [0]*100002
for i in range(3, 100001, 2):
  if (num[i]) and (num[int((i+1)/2)]):
    c[i] = c[i] + 1

for i in range(3, 100001):
  c[i] = c[i] + c[i-1]

for i in range(int(input())):
  _input = input().split(' ')
  print(c[int(_input[1])] - c[int(_input[0])-1])
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
ans = 0
flag = 0
if n % 2 == 1:
  if a.count(0) != 1: flag = 1
  else:
    sa = n-1
    while sa > 0:
      if a.count(sa) != 2:
        flag = 1
        break
      sa -= 2
else:
  if a.count(0) != 0: flag = 1
  else:
    sa = n-1
    while sa > 0:
      if a.count(sa) != 2:
        flag = 1
        break
      sa -= 2

if flag == 0:
  print(2 ** (n // 2))
else:
  print(0)

### FIXED CODE ###

import math
N = int(input())


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

A.sort()
ans = 0
flag = True
if N % 2 == 1:
  # 0,2,2,4,4,～みたいに並んでるはず
  if A[0] == 0:
    for i in range(1,N,2):
      if A[i] != i+1 or A[i+1] != i+1:
        flag = False
        break
  
    if flag: ans = 2**(N//2) % (10**9 + 7)

else:
  if A[0] != 0:
    for i in range(0,N,2):
      if A[i] != i+1 or A[i+1] != i+1:
        flag = False
        break
  
    if flag: ans = 2**(N//2) % (10**9 + 7)
    
    
    
print(ans)
### BUGGY CODE ###

import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n,k = map(int,ipt().split())
    a = list(map(int,ipt().split()))
#    n = 2*10**5
#    k = 2*10**5
#    a = [i+1 for i in range(n)]
    nxt = [-1]*(n)
    pa = [-1]*(2*10**5+1)
    for i,ai in enumerate(a*2):
        pai = pa[ai]
        if pai == -2:
            continue
        if pai == -1:
            pa[ai] = i
        else:
            nxt[pai] = i-pai+1
            if i <= n-1:
                pa[ai] = i
            else:
                pa[ai] = -2
    dbl = [nxt]
    ni = 1
    while ni <= n*k:
        nnxt = [0]*n
        pnxt = dbl[-1]
        for i in range(n):
            nnxt[i] = pnxt[i]+pnxt[(i+pnxt[i])%n]
        dbl.append(nnxt)
        ni *= 2
    np = 0
    ld = len(dbl)
    ni = len(dbl)-1
#    print(dbl)
    while ni >= 0:
        db = dbl[ni]
        if db[np%n] < n*k-1-np:
            np += db[np%n]
        else:
            ni -= 1
#        print(np)
    ans = []
    for i in range(np%n,n):
        ai = a[i]
        if ai in ans:
            ans = ans[:ans.index(ai)]
        else:
            ans.append(ai)
    print(" ".join(map(str,ans)))



    return

if __name__ == '__main__':
    main()


### FIXED CODE ###

import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n,k = map(int,ipt().split())
    a = list(map(int,ipt().split()))
#    n = 2*10**5
#    k = 2*10**5
#    a = [i+1 for i in range(n)]
    nxt = [-1]*(n)
    pa = [-1]*(2*10**5+1)
    for i,ai in enumerate(a*2):
        pai = pa[ai]
        if pai == -2:
            continue
        if pai == -1:
            pa[ai] = i
        else:
            nxt[pai] = i-pai+1
            if i <= n-1:
                pa[ai] = i
            else:
                pa[ai] = -2
    dbl = [nxt]
    ni = 1
    while ni <= n*k:
        nnxt = [0]*n
        pnxt = dbl[-1]
        for i in range(n):
            nnxt[i] = pnxt[i]+pnxt[(i+pnxt[i])%n]
        dbl.append(nnxt)
        if min(nnxt) > n*k:
            break
        ni *= 2
    np = 0
    ld = len(dbl)
    ni = len(dbl)-1
#    print(dbl)
    for db in dbl[::-1]:
        while True:
            if db[np%n] < n*k-1-np:
                np += db[np%n]
            else:
                break
#        print(np)
    ans = []
    np %= n
    while np < n:
        if nxt[np]+np > n:
            ans.append(a[np])
            np += 1
        elif nxt[np]+np == n:
            np = n
        else:
            np = nxt[np]+np
    print(" ".join(map(str,ans)))



    return

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

N,K,Q = (int(x) for x in input().split())

#initialize
score = []
for x in range(N):
	score.append(K)

#point
for x in range(Q):
	A = int(input())
	for y in range(N):
		if y+1 != A:
			score[y] -= 1;

for x in range(N):
	if score[x] > 0:
		print("Yes")
	else:
		print("No")


### FIXED CODE ###

N,K,Q = map(int, input().split())

score = [0] * N

for x in range(Q):
	A = int(input())
	score[A-1] += 1;

for x in range(N):
	if score[x] > Q - K:
		print("Yes")
	else:
		print("No")
### BUGGY CODE ###

import fileinput


def knapsack(capacity, item_weights, item_values):
    no_current_item_values = [0] * (capacity + 1)
    for i, val in enumerate(item_values):
        with_current_item_values = [0] * (capacity + 1)
        for current_capacity in range(1, capacity + 1):
            if current_capacity < item_weights[i]:
                with_current_item_values[current_capacity] = no_current_item_values[current_capacity]
            else:
                with_current_item_values[current_capacity] = max(
                    no_current_item_values[current_capacity],
                    no_current_item_values[current_capacity - item_weights[i]] + val
                )
        no_current_item_values = with_current_item_values

    return no_current_item_values[-1]


inp = fileinput.input()

first_line_split = inp.readline().split(" ")

item_count = int(first_line_split[0])
capacity = int(first_line_split[1])

item_weights = []
item_values = []
for _ in range(item_count):
    split = inp.readline().split(" ")
    item_weights.append(int(split[0]))
    item_values.append(int(split[1]))

print(knapsack(capacity, item_weights, item_values))


### FIXED CODE ###

import fileinput


def knapsack(capacity, item_weights, item_values):
    no_current_item_values = [0] * (capacity + 1)
    for i, val in enumerate(item_values):
        with_current_item_values = [0] * (capacity + 1)
        for current_capacity in range(1, capacity + 1):
            if current_capacity < item_weights[i]:
                with_current_item_values[current_capacity] = no_current_item_values[current_capacity]
            else:
                with_current_item_values[current_capacity] = max(
                    no_current_item_values[current_capacity],
                    no_current_item_values[current_capacity - item_weights[i]] + val
                )
        no_current_item_values = with_current_item_values

    return no_current_item_values[-1]


inp = fileinput.input()

first_line_split = inp.readline().split(" ")

item_count = int(first_line_split[0])
capacity = int(first_line_split[1])

item_weights = []
item_values = []
for _ in range(item_count):
    split = inp.readline().split(" ")
    item_weights.append(int(split[0]))
    item_values.append(int(split[1]))

print(knapsack(capacity, item_weights, item_values))
### BUGGY CODE ###

R, C, K = map(int, input().split())
V = [[[] for _ in range(C)] for _ in range(R)]
for _ in range(K):
  r, c, v = map(int, input().split())
  V[r-1][c-1].append(v)
M = [[[0, 0, 0, 0] for _ in range(C)] for _ in range(R)]
# M[r][c][count in column (c)]
for r in range(R):
  for c in range(C):
    V[r][c].sort(reverse=True)
    candidates = [[0] for _ in range(4)]
    #print(candidates)
    for n_pick in range(1 + min(3, len(V[r][c]))):
      candidates[n_pick].append(sum(V[r][c][:n_pick]))
      if r > 0:
        for n_prev in range(4):
          #print('R++', r, c, n_pick, n_prev)
          if M[r-1][c][n_prev] > 0 or n_prev == 0:
            candidates[n_pick].append(
              M[r-1][c][n_prev] + sum(V[r][c][:n_pick]))
      if c > 0:
        for n_prev in range(4 - n_pick):
          #print('C++', r, c, n_pick, n_prev)
          if  M[r][c-1][n_prev]  > 0 or n_prev == 0:
            candidates[n_prev+n_pick].append(
              M[r][c-1][n_prev] + sum(V[r][c][:n_pick]))
    #print(candidates)
    #print(r, c, candidates, M)
    for i in range(4):
      M[r][c][i] = max(candidates[i])
    #print(r, c, M)
#print(V, M)
print(max(M[R-1][C-1]))

### FIXED CODE ###

R, C, K = map(int, input().split())
V = [[0 for _ in range(C)] for _ in range(R)]
for _ in range(K):
  r, c, v = map(int, input().split())
  V[r-1][c-1] = v
M = [0] * R * C * 4 
# M[r*C*4 + c*4 + i]
# M[(r-1)*C*4 + c*4 + i]
# M[r*C*4 + (c-1)*4 + i]
# M[r][c][count in column (c)]
for r in range(R):
  for c in range(C):
    for n_pick in [0, 1] if V[r][c] else [0]:
      M[r*C*4 + c*4 +n_pick] = max(M[r*C*4 + c*4 +n_pick], n_pick*V[r][c])
      if r > 0:
        for n_prev in range(4):
          #print('R++', r, c, n_pick, n_prev)
          if M[(r-1)*C*4 + c*4 +n_prev] > 0 or n_prev == 0:
            M[r*C*4 + c*4 +n_pick]=max(M[r*C*4 + c*4 +n_pick],
              M[(r-1)*C*4 + c*4 +n_prev] + n_pick*V[r][c])
      if c > 0:
        for n_prev in range(4 - n_pick):
          #print('C++', r, c, n_pick, n_prev)
          if  M[r*C*4 + (c-1)*4 +n_prev]  > 0 or n_prev == 0:
            M[r*C*4 + c*4 +n_prev+n_pick]=max(M[r*C*4 + c*4 + n_prev+n_pick],
              M[r*C*4 + (c-1)*4 +n_prev] + n_pick*V[r][c])
    #print(candidates)
    #print(r, c, candidates, M)
    #for i in range(4):
    #  M[r][c][i] = max(candidates[i])
    #print(r, c, M)
#print(V, M)
print(max(M[((R-1)*C*4 + (C-1) *4):((R-1)*C*4 + (C-1) *4+4)]))
### BUGGY CODE ###

#encoding utf-8

n = int(input())
s = list(str(input()))

reverse = 3*10**5+1
for i in range(n):
    if i == 0:
        point = s[i+1:].count("E")
    elif i == n-1:
        point = s[:i-1].count("W")
    else:
        point = s[i+1:].count("E")+s[:i].count("W")
    # print(point)
    reverse = min(point, reverse)

print(reverse)


### FIXED CODE ###

#encoding utf-8

n = int(input())
s = list(str(input()))

reverse = 3*10**5+1
west = []
east = []
west_num = 0
east_num = 0
for i in range(len(s)):
    if s[i] == "W":
        west_num += 1
    elif s[i] == "E":
        east_num += 1
    west.append(west_num)
    east.append(east_num)
# print(west,east)
for i in range(n):
    if i == 0:
        point = east[-1]+east[0]
    elif i == n-1:
        point = west[i-1]
    else:
        point = east[-1]-east[i]+west[i-1]
    # print(point)
    reverse = min(point, reverse)

print(reverse)
### BUGGY CODE ###

num = list(map(int, input().split()))
H = list(map(int, input().split()))
N = num[0]
K = num[1]

dp = [1000000000] * N
dp[0] = 0
for i in range(N):
    try:
        for j in range(K):
            dp[i+1] = min(dp[i+1], dp[i-j]+abs(H[i+1]-H[i-j]))
    except:
        continue

print(dp[-1])

### FIXED CODE ###

num = list(map(int, input().split()))
H = list(map(int, input().split()))
N = num[0]
K = num[1]

dp = [float("inf")] * N
dp[0] = 0
for i in range(N):
    try:
        for j in range(K):
            dp[i+1] = min(dp[i+1], dp[i-j]+abs(H[i+1]-H[i-j]))
    except:
        continue

print(dp[-1])
### BUGGY CODE ###

import sys
input = sys.stdin.readline
a,b,n = map(int,input().split())
li = []
append = li.append
 
#for x in range(n+1):
#    append(int((a*(x))/b) - a * int(x/b))
#print(max(li))
def f(x):
    return int((a*(x))/b) - a * int(x/b) 
li = [f(x) for x in range(n+1)]
print(max(li))

### FIXED CODE ###

import math
 
A, B, N = map(int, input().split())
 
 
ans1 = 0
 
if N > B - 1:
    x = B-1
    print(int((A * x) / B) - A * int(x / B))
elif N <= B - 1:
    x = N
    print(int((A * x) / B) - A * int(x / B))
### BUGGY CODE ###

# 2020-05-22
def main():
    n, m, k = [int(x) for x in input().split()]
    friends = [set() for _ in range(n)]
    blocks = [set() for _ in range(n)]
    for _ in range(m):
        a, b = [int(x) - 1 for x in input().split()]
        friends[a].add(b)
        friends[b].add(a)
    for _ in range(k):
        a, b = [int(x) - 1 for x in input().split()]
        blocks[a].add(b)
        blocks[b].add(a)

    networks = {}  # The dict of networks as sets. Keys are leaders.
    net_leaders = [-1] * n  # The leaders of the networks that the ones joined.
    visited = [False] * n
    for person in range(n):
        if visited[person]:
            continue
        networks[person] = set()
        stack = [person]
        while stack:
            new = stack.pop()
            visited[new] = True
            net_leaders[new] = person
            networks[person].add(new)
            for adj in friends[new]:
                if visited[adj]:
                    continue
                stack.append(adj)

    answers = [0] * n
    for person in range(n):
        net = networks[net_leaders[person]]
        ans = len(net) - len(friends[person]) - 1
        for block in blocks[person]:
            if block in net:
                ans -= 1
        answers[person] = ans

    print(*answers)
    return


if __name__ == '__main__':
    main()


### FIXED CODE ###

# 2020-05-22
def main():
    n, m, k = [int(x) for x in input().split()]
    friends = [set() for _ in range(n)]
    blocks = [set() for _ in range(n)]
    for _ in range(m):
        a, b = [int(x) - 1 for x in input().split()]
        friends[a].add(b)
        friends[b].add(a)
    for _ in range(k):
        a, b = [int(x) - 1 for x in input().split()]
        blocks[a].add(b)
        blocks[b].add(a)

    networks = {}  # The dict of networks as sets. Keys are leaders.
    net_leaders = [-1] * n  # The leaders of the networks that the ones joined.
    visited = [False] * n
    for person in range(n):
        if visited[person]:
            continue
        network = set()
        network_add = network.add
        stack = [person]
        stack_append = stack.append
        stack_pop = stack.pop
        while stack:
            new = stack_pop()
            visited[new] = True
            net_leaders[new] = person
            network_add(new)
            for adj in friends[new]:
                if visited[adj]:
                    continue
                stack_append(adj)
        networks[person] = network

    answers = []
    answers_append = answers.append
    for person in range(n):
        net = networks[net_leaders[person]]
        ans = len(net) - len(friends[person]) - 1
        for block in blocks[person]:
            if block in net:
                ans -= 1
        answers_append(ans)

    print(*answers)
    return


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

import sys
import math

N = int(input())

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

sum0 = 1

for n in range(0,N):
    sum0 = sum0 * str_list[n]
if sum0 > 10**18:
    print(-1)
else:
    print(sum0)

### FIXED CODE ###

N = int(input())

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

sum0 = str_list[0]

for n in range(0,N):
    if str_list[n] == 0:
        sum0 = 0

for n in range(1,N):
    if sum0 == 0:
        break
    sum0 = sum0 * str_list[n]
    if sum0 > 10 ** 18:
        sum0 = -1
        break

print(sum0)