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


import itertools as it
import numpy as np
from functools import *
import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline


def acinput():
    return list(map(int, input().split(" ")))


def II():
    return int(input())


directions = np.array([[1, 0], [0, 1], [-1, 0], [0, -1]])
directions = list(map(np.array, directions))

mod = 10**9+7


def factorial(n):
    fact = 1
    for integer in range(1, n + 1):
        fact *= integer
    return fact


def serch(x, count):
    #print("top", x, count)

    for d in directions:
        nx = d+x
        # print(nx)
        if np.all(0 <= nx) and np.all(nx < (H, W)):
            if field[nx[0]][nx[1]] == "E":
                count += 1
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)
                continue
            if field[nx[0]][nx[1]] == "#":
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)

    return count


N, K = acinput()


ary = [acinput() for i in range(N)]
x = list(map(lambda x: x[0], sorted(ary, key=lambda s: s[0])))
y = list(map(lambda x: x[1], sorted(ary, key=lambda x: x[1])))


#print(list(it.combinations(y,2)))
#print(list(x))

res = 10**20
for sy in it.combinations(y, 2):
    #print(sy)
    for sx in it.combinations(x, 2):
        #print(sx)
        #print(sy, sx)
        count = 0
        for sa in ary:
            
            if sy[0] <= sa[1] and sa[1] <= sy[1]:
                if sx[0] <= sa[0] and sa[0] <= sx[1]:
                    count += 1

        #print(count)
        if count >= K:
            dx = np.diff(sx)[0]
            dy = np.diff(sy)[0]
            #print(dx,dy)
            res = min(res, dx*dy)
            #print(res)

print(res)



### FIXED CODE ###


import itertools as it

from functools import *
import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline


def acinput():
    return list(map(int, input().split(" ")))


def II():
    return int(input())



N, K = acinput()


ary = [acinput() for i in range(N)]
x = list(map(lambda x: x[0], sorted(ary, key=lambda s: s[0])))
y = list(map(lambda x: x[1], sorted(ary, key=lambda x: x[1])))


#print(list(it.combinations(y,2)))
#print(list(x))

res = 10**20
for sy in it.combinations(y, 2):
    #print(sy)
    for sx in it.combinations(x, 2):
        #print(sx)
        #print(sy, sx)
        count = 0
        for sa in ary:
            
            if sy[0] <= sa[1] and sa[1] <= sy[1]:
                if sx[0] <= sa[0] and sa[0] <= sx[1]:
                    count += 1

        #print(count)
        if count >= K:
            #dx = np.diff(sx)[0]
            #dy = np.diff(sy)[0]
            dx=sx[1]-sx[0]
            dy=sy[1]-sy[0]
            #print(dx,dy)
            res = min(res, dx*dy)
            #print(res)

print(res)
### BUGGY CODE ###

a = []
total = 0
N,K = list(map(int,input().split()))
number_list = list(map(int,input().split()))
for i in range(N-K+1):
    a.append(sum(number_list[i:i+K]))
b = max(a)
a = list(a)
max_pattern = a.index(b)
for r in number_list[max_pattern:max_pattern+K]:
    total += r * (1+r) / (2*r)
print(total)

### FIXED CODE ###

N,M=list(map(int,input().split()))
l_n=list(map(int,input().split()))
k=[]
j=0
for i in range(1,1001):
   j+=i
   k.append(j/i)
l_n=[k[l_n[i]-1] for i in range(N)]
ans=sum(l_n[0:M])
sum_n=ans
for i in range(N-M):
   sum_n+=l_n[i+M]
   sum_n-=l_n[i]
   ans=max(ans,sum_n)
print(ans)
### BUGGY CODE ###

n=int(input())
p=list(map(int, input().split()))
ans=0
for i in range(n):
    buf=0
    for j in range(i+1):
        if p[j]>=p[i]:
            buf+=1
    if buf==i+1:
        ans+=1
print(ans)

### FIXED CODE ###

n=int(input())
p=list(map(int, input().split()))
ans=1
l=[p[0]]
buf=p[0]
for i in range(1,n):
    l.append(p[i])
    if p[i]<=buf:
        ans+=1
        buf=p[i]
print(ans)
### BUGGY CODE ###

N,Y = map(int,input().split(" "))

t = int(Y/10000)
end=False
for x in range(0,t+1):
    for y in range(0,N+1):
        for z in range(0,N+1):
            ans = x*10000+y*5000+z*1000
            if ans==Y and x+y+z==N:
                print(str(x)+" "+str(y)+" "+str(z))
                end=True
                break
        if end:
            break
    if end:
        break
if end==False:
    print("-1 -1 -1")


### FIXED CODE ###

N,Y = map(int,input().split(" "))

t = int(Y/10000)
end=False
for x in range(0,t+1):
    for y in range(0,N+1):
        if x+y>N:
            break
        z = N-x-y
        num = x*10000+y*5000+z*1000
        if num==Y:
            print(str(x)+" "+str(y)+" "+str(z))
            end=True
            break
    if end:
        break
if end==False:
    print("-1 -1 -1")
### BUGGY CODE ###

import sys
input=sys.stdin.readline
H,W,K=map(int,input().split())
G=[[0]*W for i in range(H)]

for i in range(K):
    r,c,v=map(int,input().split())
    r,c=r-1,c-1
    G[r][c]=v

dp=[[[-1,-1,-1,-1] for i in range(W)] for i in range(H)]

dp[0][0][0]=0
if G[0][0]!=0:
    dp[0][0][1]=G[0][0]

for i in range(H):
    for j in range(W):
        m=max(dp[i][j])
        if i+1<H:
            dp[i+1][j][1]=max(dp[i+1][j][1],m+G[i+1][j])
            dp[i+1][j][0]=max(dp[i+1][j][0],m)
        if j+1<W:
                dp[i][j+1][0]=0
                dp[i][j+1][1]=max(dp[i][j+1][1],dp[i][j][1],dp[i][j][0]+G[i][j+1])
                dp[i][j+1][2]=max(dp[i][j+1][2],dp[i][j][2],dp[i][j][1]+G[i][j+1])
                dp[i][j+1][3]=max(dp[i][j+1][3],dp[i][j][3],dp[i][j][2]+G[i][j+1])
print(max(dp[H-1][W-1]))

### FIXED CODE ###

import sys
input=sys.stdin.readline
H,W,K=map(int,input().split())
G=[[0]*W for i in range(H)]

for i in range(K):
    r,c,v=map(int,input().split())
    r,c=r-1,c-1
    G[r][c]=v


dp0=[[-1 for i in range(W)] for i in range(H)]
dp1=[[-1 for i in range(W)] for i in range(H)]
dp2=[[-1 for i in range(W)] for i in range(H)]
dp3=[[-1 for i in range(W)] for i in range(H)]

dp0[0][0]=0
if G[0][0]!=0:
    dp1[0][0]=G[0][0]

for i in range(H):
    for j in range(W):
        m=max(dp0[i][j],dp1[i][j],dp2[i][j],dp3[i][j])
        if i+1<H:
            dp1[i+1][j]=max(dp1[i+1][j],m+G[i+1][j])
            dp0[i+1][j]=max(dp0[i+1][j],m)
        if j+1<W:
                dp0[i][j+1]=0
                dp1[i][j+1]=max(dp1[i][j+1],dp1[i][j],dp0[i][j]+G[i][j+1])
                dp2[i][j+1]=max(dp2[i][j+1],dp2[i][j],dp1[i][j]+G[i][j+1])
                dp3[i][j+1]=max(dp3[i][j+1],dp3[i][j],dp2[i][j]+G[i][j+1])
print(max(dp0[H-1][W-1],dp1[H-1][W-1],dp2[H-1][W-1],dp3[H-1][W-1]))
### BUGGY CODE ###

import sys
input=sys.stdin.readline
N,K,Q=map(int,input().split())
J=[int(input()) for _ in range(Q)]
for i in range(1,N+1):
    print("Yes" if K-Q+J.count(i)>0 else "No")



### FIXED CODE ###

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

N,K,Q = map(int,input().split())
A = (int(x) for x in sys.stdin.read().split())

score = [K-Q] * (N+1) 
for x in A:
    score[x] += 1

answer = '\n'.join('No' if x <= 0 else 'Yes' for x in score[1:])
print(answer)
### BUGGY CODE ###

h,w=map(int,input().split())
canMove=sum([[(i+j)%2==0 for i in range(w)]for j in range(h)],[])
print(canMove.count(True))

### FIXED CODE ###

h,w=map(int,input().split())
ans=0
if h==1 or w==1:
    ans=1
elif (h*w)%2==0:
    ans=int(h*w//2)
else:
    ans=(h*w//2+1)
print(ans)
### BUGGY CODE ###

from collections import deque

s=input()
s=deque(s)
q=int(input())
ans=''
flg=0
for _ in range(q):
	query=list(map(str,input().split()))
	if query[0]=='1':
		flg=1-flg
	else:
		if flg:
			s.reverse()
			#print(s)
			flg=0
		if query[1]=='1':
			s.appendleft(query[2])
		else:
			s.append(query[2])
if flg:
	t=[]
	for i in range(len(s)):
		t.append(s.pop())
	print(''.join(t))
else:
    print(''.join(s))

### FIXED CODE ###

from collections import deque

s=input()
s=deque(s)
q=int(input())
ans=''
flg=0
for _ in range(q):
	query=list(map(str,input().split()))
	if query[0]=='1':
		flg=1-flg
	else:
		if flg:
			if query[1]=='1':
				s.append(query[2])
			else:
				s.appendleft(query[2])
		else:
			if query[1]=='1':
				s.appendleft(query[2])
			else:
				s.append(query[2])
if flg:
	t=[]
	for i in range(len(s)):
		t.append(s.pop())
	print(''.join(t))
else:
    print(''.join(s))
### BUGGY CODE ###

import sys
input = sys.stdin.readline

class segtree:
    x_unit=0 # 単位元
    x_func=sum  # 関数
    def __init__(self,n):
        self.n=n
        self.x=[self.x_unit]*(2*n)
    def build(self, seq):
        for i,j in enumerate(seq, self.n):  # n番目からseqをx配列に移していく
            self.x[i] = j
        for i in range(self.n-1, 0, -1):
            self.x[i] = self.x_func([self.x[i*2], self.x[i*2+1]])
    def set_val(self,i,j): # 1点更新
        i += self.n
        self.x[i]=j
        while i>1:
            i//=2 # 更新後、木の上へと登っていくついでに更新
            self.x[i]=self.x_func([self.x[i*2], self.x[i*2+1]])
    def fold(self,l,r): # 区間[l, r)の最小値などを取得 
        l+=self.n
        r+=self.n
        val_l=self.x_unit
        val_r=self.x_unit
        while l<r:
            if l & 1: # lが奇数
                val_l=self.x_func([val_l,self.x[l]])
                l+=1 # 偶数に調節
            if r & 1: # rが奇数
                r-=1 # 開区間なので1個前は偶数番目の要素
                val_r=self.x_func([val_r,self.x[r]])
            l //= 2
            r //= 2
        return self.x_func([val_l,val_r])

from collections import defaultdict,deque
n,q=map(int, input().split())
c=list(map(int, input().split()))
c=[i-1 for i in c]
lr=[]
for i in range(q):
    l,r=map(int, input().split())
    lr.append((l-1,r-1))
lrsort=sorted(lr, key=lambda x:x[0])
lrsort=sorted(lr, key=lambda x:x[1])
lrsort=deque(lrsort)
#print(lrsort)
goodpos=[-1]*n
isgood=[0 for x in range(n)]
d=defaultdict(int)
s=0
seg=segtree(n)
seg.build(isgood)

while lrsort:
    l,r=lrsort.popleft()
    if s!=r+1:
        for i in range(s,r+1):
            if goodpos[c[i]]!=-1:
                seg.set_val(goodpos[c[i]],0)
            goodpos[c[i]]=i
            seg.set_val(i,1)
    s=r+1
    d[(l,r)]=seg.fold(l,r+1)

for l,r in lr:
    print(d[(l,r)])


### FIXED CODE ###

import sys
input = sys.stdin.readline
# Binary Indexed Tree (Fenwick Tree)
class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0]*(n+1)
        self.el = [0]*(n+1)
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i]
            i -= i & -i
        return s
    def add(self, i, x):
        # assert i > 0
        self.el[i] += x
        while i <= self.n:
            self.data[i] += x
            i += i & -i
    def get(self, i, j=None):
        if j is None:
            return self.el[i]
        return self.sum(j) - self.sum(i)

n,q=map(int,input().split())
c=list(map(int,input().split()))
ques=[]
from collections import defaultdict
ans=defaultdict(int)
for _ in range(q):
    l,r=map(int,input().split())
    ques.append((l,r))

sortques=sorted(ques, key=lambda x:x[1])

good=BIT(n+1)
goodind=[-1]*n
last=0
for x in range(q):
    l,r=sortques[x]
    if last!=r:
        for i in range(last, r):
            if goodind[c[i]-1]==-1:
                goodind[c[i]-1]=i
                good.add(i+1, 1)
            else:
                j=goodind[c[i]-1]
                good.add(j+1, -1)
                goodind[c[i]-1]=i
                good.add(i+1, 1)
    ans[(l,r)]=good.get(l-1,r)
    last=r

for i in range(q):
    print(ans[ques[i]])
### BUGGY CODE ###

N, M, Q = map(int, input().split())		# 5 7 2

A=[]
for i in range(M):
	l, r = map(int, input().split())		# 5 7
	A.append( (l,r) )

#print(A)

for i in range(Q):
	p, q = map(int, input().split())		# 5 7
	
	ans=0
	for a in A:
		if (p<=a[0])and(a[1]<=q): ans+=1
	else:
		print(ans)



### FIXED CODE ###

N, M, Q = map(int, input().split())		# 5 7 2

A=[]	# (l,r)をそのまま保持
B=[]	# (l,r,n) lからrまでの本数nを保持, B[l][r]=n

for i in range(N+1):
	a=[0]*(N+1)
	B.append(a)

for i in range(M):
	l, r = map(int, input().split())		# 5 7
	A.append( (l,r) )
	B[l][r]+=1

#print("A", A)
#print("B", B)

for iR in range(1,N+1):
	for iC in range(1,N+1):
		B[iR][iC] += B[iR][iC-1]

for iC in range(1,N+1):
	for iR in range(iC, 1, -1):
		B[iR-1][iC] += B[iR][iC]


#print("B", B)


for i in range(Q):
	p, q = map(int, input().split())		# 5 7
	
	print( B[p][q] )
### BUGGY CODE ###

import sys
from collections import deque
import copy
import heapq

from math import *

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, M] =  [int(input_raw[0]), int(input_raw[1])]
    graph = {}
    for i in range(M):
        input_raw = read_func().strip().split()
        [a, b, c] =  [int(input_raw[0]), int(input_raw[1]), int(input_raw[2])]
        if a not in graph:
            graph[a] = [(b, -long(c))]
        else:
            graph[a].append((b, -long(c)))

    dist_list =[long(sys.maxint) * long(sys.maxint) for i in range(N + 1)]
    dist_list[1] = 0L
    for i in range(0, 2 * N):
        for j in range(1, N + 1):
            if j not in graph:
                continue
            for edge in graph[j]:
                if dist_list[j] < long(sys.maxint) * long(sys.maxint):
                    if dist_list[j] + edge[1] < dist_list[edge[0]]:
                        dist_list[edge[0]] = dist_list[j] + edge[1]
                        if (i >= N - 1 and edge[0] == N):
                            print "inf"
                            return
    print -dist_list[N]


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
from collections import deque
import copy
import heapq

from math import *

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, M] =  [int(input_raw[0]), int(input_raw[1])]
    graph = {}
    for i in range(M):
        input_raw = read_func().strip().split()
        [a, b, c] =  [int(input_raw[0]), int(input_raw[1]), -long(input_raw[2])]
        if a not in graph:
            graph[a] = [(b, c)]
        else:
            graph[a].append((b, c))

    dummy_inf = long(sys.maxint) * long(sys.maxint)
    dist_list =[dummy_inf for i in range(N + 1)]
    dist_list[1] = 0L

    for i in range(0, 2 * N):
        for j in range(1, N + 1):
            if j not in graph:
                continue
            for edge in graph[j]:
                if dist_list[j] < dummy_inf:
                    new_cost = dist_list[j] + edge[1]
                    if new_cost < dist_list[edge[0]]:
                        dist_list[edge[0]] = new_cost
                        if (i >= N - 1 and edge[0] == N):
                            print "inf"
                            return
    print -dist_list[N]


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

import math
import bisect
Q=int(input())

querys = [list(map(int,input().split())) for x in range(Q)]

def siever(x):
  nums = [a for a in range(2,x+1)]
  primes = []
  while nums[0] <= int(math.sqrt(x))+1:
    tmp = nums.pop(0)
    primes.append(tmp)
    for num in nums:
      if num%tmp == 0:
        nums.remove(num)
        continue
  
  return (primes+nums)

L = 0
for query in querys:
  L = max(L,query[1])
primes = siever(L)
L2017= []
for prime in primes:
  if (prime+1)//2 in primes:
    L2017.append(prime)
result = [0]*(max(L2017)+1)
for l in L2017:
  result[l] = 1
for i in range(1,len(result)):
  result[i] += result[i-1]
for query in querys:
  if query[0] == query[1] and query[0] in L2017:
    print(1)
  else:
    if len(result) <= query[0]:
      print(0)
    elif len(result) <= query[1]:
      print(result[-1]-result[query[0]-1])
    else:
      print(result[query[1]]-result[query[0]-1])

### FIXED CODE ###

import math
Q=int(input())
querys = [list(map(int,input().split())) for x in range(Q)]
large = max(q[1] for q in querys)
like2017 = [0]*(large+1)

#siever
cands = [False if (5 < i and (i%2)*(i%3)*(i%5) == 0) or (i < 2) or (i == 4) else True for i in range(large+1)]
if 5 <= large:
  for i in range(6,int(math.sqrt(large)+1)):
    if cands[i]:
      for j in range(i*i,large+1,i):
        if cands[j]:
          cands[j] = False

#find 2017-like-number          
for x in range(large+1):
  if cands[x] and cands[(x+1)//2]:
    like2017[x] = 1
for y in range(1,large+1):
  like2017[y] += like2017[y-1]

for q in querys:
  print(like2017[q[1]]-like2017[q[0]-1])
### BUGGY CODE ###

h,w=map(int, input().split())
c_h,c_w=map(int, input().split())
d_h,d_w=map(int, input().split())
map=[[-1]*w for i in range(h)]
 
for gyou in range(h):
    tmp=input()
    for retu in range(w):
        if tmp[retu]=="#":map[gyou][retu]=-2
 
genzai=[[c_h-1,c_w-1]]
wapu=[[c_h-1,c_w-1]]
 
map[c_h-1][c_w-1]=0
 
def idou(gyou,retu,kaisuu):
    wapu.append([gyou,retu])
    for i in (-1,1):
        if 0<=gyou+i and gyou+i<h:
            if map[gyou+i][retu]==-1:
                map[gyou+i][retu]=kaisuu
                genzai.append([gyou+i,retu])
                wapu.append([gyou+i,retu])
                
        if 0<=retu+i and retu+i<w:
            if map[gyou][retu+i]==-1:
                map[gyou][retu+i]=kaisuu
                genzai.append([gyou,retu+i])
                wapu.append([gyou,retu+i])

def idou_wapu(gyou,retu,kaisuu):
    for i in range(-2,3):
        for j in range(-2,3):
            if 0<=gyou+i and gyou+i<h and 0<=retu+j and retu+j<w:
                if map[gyou+i][retu+j]==-1:
                    map[gyou+i][retu+j]=kaisuu+1
                    genzai.append([gyou+i,retu+j])

wapu_kaisuu=0

while len(genzai)!=0:
 
    while len(genzai)>0:
        idou(genzai[0][0],genzai[0][1],wapu_kaisuu)
        genzai.pop(0)
    
    while len(wapu)>0:
        idou_wapu(wapu[0][0],wapu[0][1],wapu_kaisuu)
        wapu.pop(0)
    
    wapu_kaisuu+=1

print(map[d_h-1][d_w-1])

### FIXED CODE ###

from collections import deque

h,w=map(int, input().split())
c_h,c_w=map(int, input().split())
d_h,d_w=map(int, input().split())
map=[[-1]*w for i in range(h)]
 
for gyou in range(h):
    tmp=input()
    for retu in range(w):
        if tmp[retu]=="#":map[gyou][retu]=-2
 
genzai=deque()
wapu=deque()
genzai.append((c_h-1,c_w-1))
wapu.append((c_h-1,c_w-1))
 
map[c_h-1][c_w-1]=0
 
def idou(gyou,retu,kaisuu):
    wapu.append((gyou,retu))
    for i in (-1,1):
        if 0<=gyou+i and gyou+i<h:
            if map[gyou+i][retu]==-1:
                map[gyou+i][retu]=kaisuu
                genzai.append((gyou+i,retu))
                wapu.append((gyou+i,retu))
                
        if 0<=retu+i and retu+i<w:
            if map[gyou][retu+i]==-1:
                map[gyou][retu+i]=kaisuu
                genzai.append((gyou,retu+i))
                wapu.append((gyou,retu+i))

def idou_wapu(gyou,retu,kaisuu):
    for i in range(-2,3):
        for j in range(-2,3):
            if 0<=gyou+i and gyou+i<h and 0<=retu+j and retu+j<w:
                if map[gyou+i][retu+j]==-1:
                    map[gyou+i][retu+j]=kaisuu+1
                    genzai.append((gyou+i,retu+j))

wapu_kaisuu=0

while len(genzai)!=0:
 
    while len(genzai)>0:
        idou(genzai[0][0],genzai[0][1],wapu_kaisuu)
        genzai.popleft()
    
    while len(wapu)>0:
        idou_wapu(wapu[0][0],wapu[0][1],wapu_kaisuu)
        wapu.popleft()
    
    wapu_kaisuu+=1

    if map[d_h-1][d_w-1]!=-1:
        print(map[d_h-1][d_w-1])
        exit()


print(map[d_h-1][d_w-1])
### BUGGY CODE ###

#coding: utf-8
import math
m,n = map(int,input().split())
ans = 1

# GCD(Grate Common Divisier) を求める
def gcd(x,y):
    if y==0:
        return x
    else:
        return gcd(y,x%y)

gcd_cnt = gcd(m,n)
# print(gcd_cnt)

# GCDの約数を素因数分解する
flg = 0
i = 2
aaa = gcd_cnt
while i <= gcd_cnt:
    # print(str(i)+str(',')+str(gcd_cnt))
    if gcd_cnt % i == 0:
        flg = 1
        gcd_cnt = gcd_cnt // i
    else:
        if flg == 1:
            ans +=1
            flg = 0
        i+=1
    if i > aaa/2:
        i = aaa
if flg == 1:
    ans += 1

# if m % 2 == 0 and n % 2 == 0:
#     div.append(2)

# for i in range(1,m+1):
#     # print(i)
#     if m % i == 0 and n % i == 0:
#         ans += 1
#         # m = m / i
#         # n = n / i
#         div.append(i)
#         # for j in range(2,len(div)):
#         #     if i % div[j] == 0:
#         #         flg = 1
#         #         break
#         # if flg == 0:
#         #     div.append(i)
#         # else:
#         #     flg = 0
    
# print(" ".join(map(str,div)))
# div.sorted(reversed=True)

# for j in range(1,div[0]):
#     div[0] % j


# # print(len(div))
print(ans)


### FIXED CODE ###

#coding: utf-8
from fractions import gcd
import math

# GCDの約数を素因数分解する
def primeFactor(n):
    flg = 0
    count = 0
    tmp = math.sqrt(n)
    i = 2

    if n == 1:
        return 1

    while i <= tmp:
        # print(str(i)+str(',')+str(gcd_cnt))
        if n % i == 0:
            if flg == 0:
                flg = 1
                count += 1
            n = n // i
        else:
            flg = 0
            i += 1
    # if flg == 1:
    #     count += 1
    # print(str('素数=')+str(count)+str(' n=')+str(n)+str(' i=')+str(i))
    if n > 1:
        count += 1
    # 1を足す
    count += 1
    return count


# # print(len(div))
m,n = map(int,input().split())
p = gcd(m,n)
# print(str('gcd=')+ str(p))
ans = primeFactor(p)
print(ans)
### BUGGY CODE ###

MALE = 0
FEMALE = 1

def query(i):
    print(i, flush=True)
    s = input()
    if s == 'Vacant':
        exit()

    if s == 'Male':
        return(MALE)
    else:
        return(FEMALE)

def search(start, end, start_gendar):
    i = (end - start)//2
    g = query(start + i)
    if (i%2 == 0 and g != start_gendar) or (i%2 != 0 and g == start_gendar):
        return (start, start+i, start_gendar)
    return (start+i, end, g)

def main():
    n = int(input())
    start = 0
    end = n
    gendar = query(0)
    for i in range(20):
        start_new, end_new, gendar_new = search(start, end, gendar)
        start = start_new
        end = end_new
        gendar = gendar_new

if __name__ == "__main__":
    main()

### FIXED CODE ###

MALE = 0
FEMALE = 1

def query(i):
    print(i, flush=True)
    s = input()
    if s == 'Vacant':
        exit()

    if s == 'Male':
        return(MALE)
    else:
        return(FEMALE)

def search(start, end, start_gendar):
    i = (end - start)//2
    g = query(start + i)
    if (i%2 == 0 and g != start_gendar) or (i%2 != 0 and g == start_gendar):
        return (start, start+i, start_gendar)
    return (start+i, end, g)

def main():
    n = int(input())
    start = 0
    end = n
    gendar = query(0)
    for i in range(20):
        start_new, end_new, gendar_new = search(start, end, gendar)
        start = start_new
        end = end_new
        gendar = gendar_new

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

# -*- coding: utf-8 -*-

n = int(input())
num = list(map(int, input().split()))
ans = 0
flg = 0
for i in range(n):
    if num[i] == 0:
        flg = 1;
        break
    
for i in range(n):
    if i == 0:
        ans = num[0]
    else:
        ans*=num[i]
    
    if ans > 10 ** 18 and flg ==0:
        print(-1)
        break
    

if ans <= 10 ** 18:
    print(ans)

### FIXED CODE ###

# -*- coding: utf-8 -*-

n = int(input())
num = list(map(int, input().split()))
ans = 0
flg = 0
for i in range(n):
    if num[i] == 0:
        flg = 1;
        break
    
for i in range(n):
    if flg == 1:
        print(0)
        break
    elif i == 0:
        ans = num[0]
    else:
        ans*=num[i]
    
    if ans > 10 ** 18 and flg ==0:
        print(-1)
        break
    

if ans <= 10 ** 18 and flg == 0:
    print(ans)