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

[N,L] = [int(x) for x in input().split()]
A = {}
B = [0]*N
ANS = {}
count = 0
for i,x in enumerate(input().split()):
    i = int(i)
    x = int(x)
    B[i] = x
    if x in A : A[x] += [i]
    else : A[x] = [i]
for i in sorted(A) :
    for j in A[i] :
        for k in range(L) :
            if j + k not in ANS :
                ANS[j+k] = i
                count += 1
    if count + L*0.5 > N : break
        
for i in range(L):
    if i not in ANS : ANS[i] = min(B[:i+1])
for i in range(L,N):
    if i not in ANS : ANS[i] = min(B[i+1-L:i+1])
for i in range(L-1,N-1) : print(ANS[i], end=" ")
print(ANS[N-1])

### FIXED CODE ###

def ascend(a,b):
    mini = min(A[a:a+L])
    ans[a] = mini
    for i in range(a+1,b):
        if A[i+L-1] <= mini : mini = A[i+L-1]
        elif A[i-1] == mini : mini = min(A[i:i+L])
        ans[i] = mini

def descend(a,b):
    mini = min(A[b-1:b+L-1])
    ans[b-1] = mini
    for i in range(b-2,a-1,-1):
        if A[i] <= mini : mini = A[i]
        elif A[i+L] == mini: mini = min(A[i:i+L])
        ans[i] = mini
    
[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = [None]*(N-L+1)
count = 0;
if N > 10 ** 4:
    for i in range(100):
        if A[i+1] > A[i] : count += 1
    if count > 80 : descend(0, N-L+1)
    else : ascend(0,N-L+1)
else :
    ascend(0, N-L+1)
for i in ans[:-1] : print(i, end=" ")
print(ans[-1])
### BUGGY CODE ###

n=int(input())
a=[int(input()) for i in range(n)]
for i in range(n):
  x=a[:i]+a[i+1:]
  print(max(x))

### FIXED CODE ###

n=int(input())
a=[int(input()) for i in range(n)]
b=[a[i] for i in range(n)]
b.sort()
m=b[n-1]
m2=b[n-2]
for i in range(n):
  if a[i]==m:
    print(m2)
  else:
    print(m)
### BUGGY CODE ###

n = int(input())
a = input().split()
l = [0] * 30
for i in range(n):
	a[i] = format(int(a[i]), "030b")
	for j in range(30):
		l[j] += int(str(a[i])[j])
for i in range(30):
	l[i] = l[i] % 2
b = ""
for i in range(30):
	b += str(l[i])
b = int(b, 2)
for i in range(n):
	a[i] = b ^ int(a[i], 2)
print(" ".join(map(str, a)))

### FIXED CODE ###

n = int(input())
a = input().split()
l = 0
for i in range(n):
	a[i] = int(a[i])
	l = l ^ a[i]
for i in range(n):
	a[i] = l ^ a[i]
print(" ".join(map(str, a)))
### BUGGY CODE ###

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

for i in A:
    ans *=i
    
if ans > 10**18:
    print(-1)
else:
    print(ans)


### FIXED CODE ###

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

for i in A:
    if i == 0: 
        ans = 0
        break
    elif ans > 10**18:
        break
    else:
        ans *=i

if ans > 10**18:
    print(-1)
else:
    print(ans)
### BUGGY CODE ###

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

for i in range(N):
    A_num = A.pop(i)
    print(max(A))
    A.insert(i, A_num)

### FIXED CODE ###

n = int(input())
a = [int(input()) for _ in range(n)]
b = sorted(a)[::-1]
mx = b[0]
mx2 = b[1]

for i in a:
    if i == mx:
        print(mx2)
    else:
        print(mx)
### BUGGY CODE ###

from collections import deque

H, W = map(int, input().split())
C = [['#' for j in range(W + 2)] for i in range(H + 2)]

for i in range(H):
    s = input()
    for j in range(W):
        C[i + 1][j + 1] = s[j]
ans = 0

SS = set([])
for sy in range(1, H + 1):
    for sx in range(1, W + 1):
        for gy in range(1, H + 1):
            for gx in range(1, W + 1):
                if (sy,sx, gy, gx) in SS:
                    continue
                else:
                    SS.add((gy, gx, sy, sx))
                q = deque()
                q.append((sy, sx, 0))
                S = set([])
                r = 0
                while len(q) > 0:
                    t = q.popleft()
                    y, x, d = t[0], t[1], t[2]
                    if C[y][x] == '#':
                        continue
                    if (y, x) in S:
                        continue
                    else:
                        S.add((y, x))

                    if (y, x) == (gy, gx):
                        r = d
                        break
                    q.append((y + 1, x , d + 1))
                    q.append((y - 1, x, d + 1))
                    q.append((y, x + 1, d + 1))
                    q.append((y, x - 1, d + 1))

                ans = max(ans, r)


print(ans)




### FIXED CODE ###

from collections import deque

H, W = map(int, input().split())
C = [['#' for j in range(W + 2)] for i in range(H + 2)]

for i in range(H):
    s = input()
    for j in range(W):
        C[i + 1][j + 1] = s[j]
ans = 0

for sy in range(1, H + 1):
    for sx in range(1, W + 1):

        q = deque()
        q.append((sy, sx, 0))
        S = set([])
        while len(q) > 0:
            t = q.popleft()
            y, x, d = t[0], t[1], t[2]
            ans = max(d, ans)
            if C[y][x] == '#':
                continue
            if (y, x) in S:
                continue
            else:
                S.add((y, x))

            q.append((y + 1, x , d + 1))
            q.append((y - 1, x, d + 1))
            q.append((y, x + 1, d + 1))
            q.append((y, x - 1, d + 1))




print(ans - 1)
### BUGGY CODE ###

import re
import itertools

n = int(input())
ls = [input() for _ in range(n)]
new_ls = []
ans = 0

for name in ls:
    if re.match(r"[MARCH]", name):
        new_ls.append(name[:1])

comb_ls = list(itertools.combinations(new_ls, 3))


if new_ls:
    for comb in comb_ls:
        s = set(comb)
        if len(s) == 3:
            ans += 1
    print(ans)
else:
    print(0)
    quit()


### FIXED CODE ###

import itertools
n = int(input())
ls = [input()[:1] for _ in range(n)]
ans = 0
cmb = list(itertools.combinations(list("MARCH"), 3))

for c in cmb:
    ans += ls.count(c[0]) * ls.count(c[1]) * ls.count(c[2])

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

def main():
  import heapq as hq
  N, Q = list(map(int, input().split()))
  STX = [list(map(int, input().split())) for _ in range(N)]
  D = [int(input()) for _ in range(Q)]

  L = []
  for s, t, x in STX:
    L.append([x, s - x, t - x])

  L.sort(key = lambda x: x[1])
  q = []
  push = hq.heappush
  pop = hq.heappop
  cnt = 0
  for i in range(Q):
    while cnt < len(L) and D[i] >= L[cnt][1]:
      push(q, L[cnt])
      cnt += 1
    while True:
      if q == []:
        print(-1)
        break
      t = pop(q)
      if t[2] > D[i]:
        print(t[0])
        push(q, t)
        break    

main()

### FIXED CODE ###

import heapq
def main():
  N, Q = list(map(int, input().split()))
  STX = tuple(list(map(int, input().split())) for _ in range(N))
  D = tuple([int(input()) for _ in range(Q)])

  L = []
  for s, t, x in STX:
    L.append((x, s - x, t - x))

  L.sort(key = lambda x: x[1])
  q = []
  cnt = 0
  push = heapq.heappush
  pop = heapq.heappop
  t = []
  for i in range(Q):
    while cnt < len(L) and D[i] >= L[cnt][1]:
      if t != []:
        push(q, t)
        t = []
      push(q, L[cnt])
      cnt += 1
    if t != [] and t[2] > D[i]:
      print(t[0])
    else:
      while q != []:
        t = pop(q)
        if t[2] > D[i]:
          print(t[0])
          break
      else:
        t = []
        print(-1)

main()
### BUGGY CODE ###

N, M = map(int, input().split())
S = [list(map(int, input().split())) for i in range(M)]
ans = set(range(S[0][0], S[0][1] + 1))
for s in S[1:] :
    a = set(range(s[0], s[1] + 1))
    ans = ans & a
print(len(ans))

### FIXED CODE ###

import collections
N, M = map(int, input().split())
S = [list(map(int, input().split())) for i in range(M)]
smax = max([s[0] for s in S])
smin = min([s[1] for s in S])
if smin - smax + 1 >= 0 :
    print(smin - smax + 1)
else :
    print(0)


#S2 = [set(range(s[0], s[1] + 1)) for s in S]
#S3 = set.intersection(*S2)
#print(len(S3))

#ans = set(range(S[0][0], S[0][1] + 1))
#for s in S[1:] :
#    a = set(range(s[0], s[1] + 1))
#    ans = ans & a
#    if len(ans) == 0 :
#        break
#print(len(ans))
### BUGGY CODE ###

from collections import deque
inf=10**9


def BFS():
    point=0
    color=[["white" for _ in range(w)] for _ in range(h)]
    D=[[inf for _ in range(w)] for _ in range(h)]

    queue=deque([])
    for i in range(h):
        for j in range(w):
            if A[i][j]=="#":
                queue.append([i,j])
                D[i][j]=0

    while len(queue)>0:
        x,y=queue.popleft()
        for a,b in [[1,0],[-1,0],[0,1],[0,-1]]:
            X,Y=x+a,y+b
            if 0<=X<h and 0<=Y<w:
                if color[X][Y]!="black" and D[X][Y]>D[x][y]+1:
                    color[X][Y]="gray"
                    D[X][Y]=D[x][y]+1
                    point=max(point,D[X][Y])
                    queue.append([X,Y])
        color[x][y]="black"

    return point


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

### FIXED CODE ###

import sys
from collections import deque
sys.setrecursionlimit(10**7)
inf=10**7


def BFS():
    color=[["white" for _ in range(w+2)] for _ in range(h+2)]
    D=[[inf for _ in range(w+2)] for _ in range(h+2)]

    queue=deque([])
    for i in range(1,h+1):
        for j in range(1,w+1):
            if A[i][j]=="#":
                queue.append([i,j])
                D[i][j]=0
                color[i][j]="gray"

    cnt=0
    while len(queue)!=0:
        a,b=queue.popleft()
        for c,d in ((1,0),(0,1),(-1,0),(0,-1)):
            X,Y=a+c,b+d
            if A[X][Y]=="." and color[X][Y]=="white":
                color[X][Y]="gray"
                D[X][Y]=D[a][b]+1
                cnt=max(cnt,D[X][Y])
                queue.append([X,Y])
        color[a][b]="black"

    return cnt


h,w=map(int,input().split())
A=[["#"]+list(input())+["#"] for _ in range(h)]
A.insert(0,["#"]*(w+2))
A.append(["#"]*(w+2))
print(BFS())
### BUGGY CODE ###

def sol():
    import sys
    input=sys.stdin.readline
    h,w,n=map(int,input().split())
    d={}
    for i in range(n):
        y,x=map(int,input().split())
        if y in d:
            d[y].add(x)
        else:
            d[y]={x}
    for i in range(1,h+1):
        for j in range(1,w+1):
            pass
    ans=[0]*10
    for i in range(3,h+1):
        for j in range(3,w+1):
            chk=0
            if i in d:
                chk+=0+(j in d[i])+(j-1 in d[i])+(j-2 in d[i])
            if i-1 in d:
                chk+=0+(j in d[i-1])+(j-1 in d[i-1])+(j-2 in d[i-1])
            if i-2 in d:
                chk+=0+(j in d[i-2])+(j-1 in d[i-2])+(j-2 in d[i-2])
            ans[chk]+=1
    for i in ans:
        print(i)

if __name__=="__main__":
    sol()


### FIXED CODE ###

def sol():
    import sys
    input=sys.stdin.readline
    h,w,n=map(int,input().split())
    d={}
    for i in range(n):
        y,x=map(int,input().split())
        if (y,x) in d:
            d[(y,x)]+=1
        else:
            d[(y,x)]=1
        if y+1<=h and (y+1,x) in d:
            d[(y+1,x)]+=1
        elif y+1<=h:
            d[(y+1,x)]=1
        if y+2<=h and (y+2,x) in d:
            d[(y+2,x)]+=1
        elif y+2<=h:
            d[(y+2,x)]=1
 
        if x+1<=w and (y,x+1) in d:
            d[(y,x+1)]+=1
        elif x+1<=w:
            d[(y,x+1)]=1
        if x+2<=w and (y,x+2) in d:
            d[(y,x+2)]+=1
        elif x+2<=w:
            d[(y,x+2)]=1
        if x+1<=w and y+1<=h and (y+1,x+1) in d:
            d[(y+1,x+1)]+=1
        elif x+1<=w and y+1<=h:
            d[(y+1,x+1)]=1
        if x+2<=w and y+1<=h and (y+1,x+2) in d:
            d[(y+1,x+2)]+=1
        elif x+2<=w and y+1<=h:
            d[(y+1,x+2)]=1
        if x+1<=w and y+2<=h and (y+2,x+1) in d:
            d[(y+2,x+1)]+=1
        elif x+1<=w and y+2<=h:
            d[(y+2,x+1)]=1
        if x+2<=w and y+2<=h and (y+2,x+2) in d:
            d[(y+2,x+2)]+=1
        elif x+2<=w and y+2<=h:
            d[(y+2,x+2)]=1
    ans=[0]*10
    for i in d:
        if i[0]>2 and i[1]>2:
            ans[d[i]]+=1
 
    ans[0]=h*w-sum(ans)-w*2-h*2+4
    for i in ans:
        print(i)
        
if __name__=="__main__":
    sol()
### BUGGY CODE ###

N = int(input())
A=[]
B=[]
for i in range(N):
  a,b = input().split()
  A.append(int(a))
  B.append(int(b))
for j in range(N-1):
  for i in range(N-1):
    if B[i] > B[i + 1]:
      B[i], B[i + 1] = B[i + 1], B[i]
      A[i], A[i + 1] = A[i + 1], A[i]
count = 0
sum = 0
for i in range(N):
  sum = sum + A[i]
  if sum > B[i]:
    count = 1
    break
if count == 0:
  print("Yes")
else:
  print("No")
  

### FIXED CODE ###

N = int(input())
task = []
for i in range(N):
  a,b = input().split()
  task.append([int(a),int(b)])
task.sort(key=lambda x:x[0])
task.sort(key=lambda x:x[1])
count = 0
sum = 0
for i in range(N):
  sum = sum + task[i][0]
  if sum > task[i][1]:
    count = 1
    break
if count == 0:
  print("Yes")
else:
  print("No")
### BUGGY CODE ###

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

for a in A:
    mal = mal * a
if mal <= 10 ** 18:
    print(mal)
else:
    print(-1)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 8)
input = sys.stdin.readline

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

    if A.count(0):
        print(0)
        return

    ans = 1
    for a in A:
        ans = ans * a
        if ans > 10 ** 18:
            print(-1)
            return
    print(ans)

Main()
### BUGGY CODE ###

H,W = map(int,input().split())
maze = []
pad = ' ' * (W+2)
maze.append(pad)
for i in range(H):
  m = input()
  maze.append(' ' + m + ' ')
maze.append(pad)
  
def bfs(maze, x,y, score):
    queue = [(x,y,0)]
    visited = {}
    while queue:
      x,y,s = queue.pop(0)
      if maze[x][y] != '.':
        continue
      visited[(x,y)] = s
      if (x+1,y) not in visited:
        queue.append((x+1,y,s+1))
      if (x-1,y) not in visited:
        queue.append((x-1,y,s+1))
      if (x,y+1) not in visited:
        queue.append((x,y+1,s+1))
      if (x,y-1) not in visited:
        queue.append((x,y-1,s+1))
    return max(visited.values())
  
ans = -1
for h in range(1,H+1):
  for w in range(1,W+1):
    now = maze[h][w]
    if now == '#':
      continue
    if maze[h-1][w] == maze[h+1][w] == maze[h][w-1] == maze[h][w+1] == '.':
      continue
    a = bfs(maze,h,w,0)
    if a > ans:
      ans = a
print(ans)

### FIXED CODE ###

h,w = map(int,input().split())
maze = [input() for _ in range(h)]
from collections import deque
D = [(0,1),(1,0),(-1,0),(0,-1)]
ans = 0
for i in range(h):
  for j in range(w):
    if maze[i][j]=='#':
      continue
    queue  = deque([(i,j,0)])
    checked = [[0 for _ in range(w)] for _ in range(h)]
    checked[i][j] = 1
    while queue:
      j,k,d = queue.popleft()
      for dx,dy in D:
        x,y = j+dx,k+dy
        if not(0<=x<h) or not(0<=y<w):
          continue
        if maze[x][y] == '#':
          continue
        if checked[x][y]:
          continue
        checked[x][y] = d+1
        queue.append((x,y,d+1))
    for j in range(h):
      for k in range(w):
        if checked:
          ans = max(ans,checked[j][k])

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

N, K, Q = map(int, input().split(' '))
res = [K for _ in range(N)]
for i in range(Q):
    a = int(input()) - 1
    res = list(map(lambda n: n-1, res))
    res[a] = res[a] + 1
for i in range(N):
    print('Yes' if res[i] > 0 else 'No')


### FIXED CODE ###

N, K, Q = map(int, input().split(' '))
res = [0 for _ in range(N)]
for i in range(Q):
    a = int(input()) - 1
    res[a] = res[a] + 1
res = list(map(lambda n: n - Q + K, res))
for i in range(N):
    print('Yes' if res[i] > 0 else 'No')
### BUGGY CODE ###

import bisect

n = int(input())
ans_head=[-1]
for i in range(n):
  a=int(input())
  if min(ans_head)>=a:
    ans_head=[a]+ans_head
  else:
    insert_index = bisect.bisect_left(ans_head,a)
    ans_head[insert_index-1]=a

  #print(ans_head)
print(len(ans_head))

### FIXED CODE ###

import bisect
n=int(input())
A=[]
for i in range(n):
  A.append(int(input()))
Ans=[A[-1]]
for i in reversed(range(n-1)):
  a=A[i]
  if a>=Ans[-1]:
    Ans.append(a)
  else:

    Ans[bisect.bisect_right(Ans,a)]=a

print(len(Ans))
### BUGGY CODE ###

import math
n,k = map(int,input().split())
m =1
for i in range(k//n+1)[::-1]:
    if k%i==0 and k//i>=n:
        m= i
        break
print(m)

### FIXED CODE ###

n,k = map(int,input().split())
m =1
for i in range(k//n+1)[::-1]:
    if k%i==0 and k//i>=n:
        m= i
        break
print(m)
### BUGGY CODE ###

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

def main():
    ans = float('inf')
    for i in range(1, N):
        ans = min(ans, abs(sum(A[:i]) - sum(A[i:])))
    print(ans)

if __name__ == '__main__':
    main()


### FIXED CODE ###

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

def main():
    sum_n = sum(A)
    mid = sum_n / 2
    a = 0
    abs_list = []
    for i in range(N - 1):
        a += A[i]
        abs_list.append((abs(mid - a), i))    
    abs_list.sort()
    idx = abs_list[0][1]

    left = sum(A[:idx + 1])
    right = sum(A[idx + 1:])
    print(abs(left - right))

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

# coding: utf-8
# Your code here!
from functools import lru_cache
import sys
sys.setrecursionlimit(10**6)

n,m = [int(i) for i in input().split()]

#ko = [[] for _ in range(n)]
oya = [[] for _ in range(n)]
for _ in range(m):
    x,y = [int(i)-1 for i in input().split()]
#    ko[x].append(y)
    oya[y].append(x)

#memo = [-1]*n

@lru_cache()
def longest(v): #nを終点とするlongest
#    if memo[v] >= 0:
#        return memo[v]
#    else:
    c=0
    for j in oya[v]:
        c = max(c,longest(j)+1)
#    memo[v] = c
    return c

memo = [longest(i) for i in range(n)]

print(max(memo))    
#print(memo)


### FIXED CODE ###

# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)

n,m = [int(i) for i in input().split()]

#ko = [[] for _ in range(n)]
oya = [[] for _ in range(n)]
for _ in range(m):
    x,y = [int(i)-1 for i in input().split()]
#    ko[x].append(y)
    oya[y].append(x)

memo = [-1]*n

def longest(v): #nを終点とするlongest
    if memo[v] >= 0:
        return memo[v]
    else:
        c=0
        for j in oya[v]:
            c = max(c,longest(j)+1)
        memo[v] = c
        return c

for i in range(n):
    longest(i)

print(max(memo))    
#print(memo)
### BUGGY CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))
num=0
ans=[0]*n
def abs_1(num1):
    return(abs(num1))
for i in range(k):
    ans=[0]*n
    for j in range(n):
        for l in range(n):
            if abs_1(j-l)<=a[l]:
                ans[j]+=1
    a=ans
print(*a)


### FIXED CODE ###

import math
n,k=map(int,input().split())
a=list(map(int,input().split()))
ans=[0]*n
num=[]
if k>41:
    ans=[n]*n
    print(*ans)
else:
    def c(num1,num2,num3):
        num[max(0,num1-num2)]+=1
        num[min(num3,num1+num2+1)]-=1
    for i in range(k):
        num=[0]*(n+1)
        for j in range(n):
            c(j,a[j],n)
        num5=0
        for j in range(n):
            num5+=num[j]
            a[j]=num5
        if sum(a)==n*n:
            break
    print(*a)
### BUGGY CODE ###

import sys
import bisect

input = sys.stdin.readline

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

STX = [list(map(int, input().split())) for _ in range(N)]
# xの昇順に工事の区間をsort
STX = sorted(STX, key=lambda x: x[2])

D = [int(input()) for _ in range(Q)]
ans = [-1 for _ in range(Q)]
for stx in STX:
    s, t, x = stx
    left = bisect.bisect_left(D, s - x - 0.5)
    right = bisect.bisect_left(D, t - x - 0.5)
    
    for i in range(left, right):
        if ans[i] == -1:
            ans[i] = x

for a in ans:
    print(a)

### FIXED CODE ###

import sys
import bisect

input = sys.stdin.readline

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

STX = [list(map(int, input().split())) for _ in range(N)]
# xの昇順に工事の区間をsort
STX = sorted(STX, key=lambda x: x[2])

D = [int(input()) for _ in range(Q)]
ans = [-1] * Q
index = [-1] * Q
for s, t, x in STX:
    left = bisect.bisect_left(D, s - x - 0.5)
    right = bisect.bisect_left(D, t - x - 0.5)
    now = left
    while now < right:
        if index[now] == -1:  # まだansが更新されていない場合
            ans[now] = x
            index[now] = right
            now += 1
        else:
            now = index[now]
            

for a in ans:
    print(a)
### BUGGY CODE ###

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

def gcd(a, b):
	if b == 0:
		return(a)
	else :
		return gcd(b, a % b)
		
a = gcd(A, B)
ctr = 1
gusu = 0

for i in range(2, a + 1):
	if not (gusu == 1 and i % 2 == 0):
		do = 0
		while a % i == 0:
			a /= i
			do = 1
			if a == 1:
				break
		if do:
			ctr += 1
		if do and i == 2:
			gusu = 1
		if a == 1:
			break
		
print(ctr)

### FIXED CODE ###

import math
A, B = map(int, input().split())

def gcd(a, b):
	if b == 0: return(a)
	else : return gcd(b, a % b)
		
G = gcd(A, B)
ctr = 1
for i in range(2, int(math.sqrt(G)) + 1):
    if G == 1: 
        break
    if G % i == 0: 
        ctr += 1
    while G % i == 0:
        G /= i
        
if G == 1:        
    print(ctr)
else:
    print(ctr + 1)
### BUGGY CODE ###

N = int(input())
num_list = list(map(int, input().split()))
ans = num_list[0]
for i in range(1, N):
    ans *= num_list[i]

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

### FIXED CODE ###

import numpy as np
N = int(input())
num_list = list(map(int, input().split()))

# ans = np.prod(num_list)
ans = num_list[0]
for i in range(1, N):
    if ans > 10**18:
        break
    ans *= num_list[i]


if 0  in num_list:
    print(0)
elif ans > 10**18:
    print("-1")
else:
    print(ans)
### BUGGY CODE ###

s1 = list(input())
s2 = list(input())
n = len(s1)
m = len(s2)
dp = [[0]*(m+1) for _ in range(n+1)]
for i in range(1,n+1):
    for j in range(1, m+1):
        if s1[i-1] == s2[j-1]:
            dp[i][j] = 1 + dp[i-1][j-1]
        else:
            dp[i][j] = max(dp[i-1][j], dp[i][j-1])
res = []
i, j = n, m
while i > 0 and j > 0:
    if s1[i-1] == s2[j-1]:
        res.append(s1[i-1])
        i -= 1
        j -= 1
    elif dp[i][j] == dp[i-1][j]:
        i -= 1
    else:
        j -= 1
print(''.join(res[::-1]))
        

### FIXED CODE ###

s1 = list(input())
s2 = list(input())
n = len(s1)
m = len(s2)
dp = [[0]*(m+1) for _ in range(n+1)]
for i in range(1,n+1):
    for j in range(1, m+1):
        if s1[i-1] == s2[j-1]:
            dp[i][j] = 1 + dp[i-1][j-1]
        else:
            dp[i][j] = max(dp[i-1][j], dp[i][j-1])
res = []
i, j = n, m
while i > 0 and j > 0:
    if dp[i][j] == dp[i][j-1]:
        j -= 1
    elif dp[i][j] == dp[i-1][j]:
        i -= 1
    else:
        res.append(s1[i-1])
        i -= 1
        j -= 1
print(''.join(res[::-1]))
### BUGGY CODE ###

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

for i in range(N):
    tmp = X[:i] + X[i + 1:]
    tmp.sort()
    print(tmp[N // 2 - 1])

### FIXED CODE ###

N = int(input())
X = list(map(int, input().split()))
tmp = X[:]
tmp.sort()
left, right = (tmp[N // 2 - 1], tmp[N // 2])
for i in range(N):
    if X[i] > left:
        print(left)
    else:
        print(right)