Harryxun/stf_run huggingface dataset:
from collections import deque
n , k = map(int,input().split())
a = list(map(int,input().split()))
mod = 10**9 + 7
a.sort(reverse=True)
ans = 1
plus = []
minus = []

if n == k:
    for i in range(n):
        ans *= a[i]
        ans %= mod
    print(ans)
    exit()
    
for i in range(n):
    if a[i] >= 0:
        plus.append(a[i])
    elif a[i] < 0:
        minus.append(a[i])
if not plus and k % 2 == 1:
    minus.sort(reverse=True)
    for i in minus:
        ans *= minus
        ans %= mod
    print(ans)
    exit()
plus.sort(reverse=True)
minus.sort()
plus = deque(plus)
minus = deque(minus)
cou = []
while True:
    if len(cou) == k:
        break
    elif len(cou) == k-1:
        cou.append(plus.popleft())
        break
    else:
        if len(plus)>=2 and len(minus)>=2:
            p1 = plus.popleft()
            p2 = plus.popleft()
            m1 = minus.popleft()
            m2 = minus.popleft()
            if p1*p2 > m1*m2:
                cou.append(p1)
                cou.append(p2)
                minus.appendleft(m2)
                minus.appendleft(m1)
            else:
                cou.append(m1)
                cou.append(m2)
                plus.appendleft(p2)
                plus.appendleft(p1)
        elif len(plus) < 2:
            m1 = minus.popleft()
            m2 = minus.popleft()
            cou.append(m1)
            cou.append(m2)
        elif len(minus) < 2:
            p1 = plus.popleft()
            p2 = plus.popleft()
            cou.append(p1)
            cou.append(p2)
        
for i in cou:
    ans *= cou
    ans %= mod
print(ans)

### FIXED CODE ###

from collections import deque
n , k = map(int,input().split())
a = list(map(int,input().split()))
mod = 10**9 + 7
ans = 1
plus = []
minus = []

if n == k:
    for i in range(n):
        ans *= a[i]
        ans %= mod
    print(ans)
    exit()
    
for i in range(n):
    if a[i] >= 0:
        plus.append(a[i])
    elif a[i] < 0:
        minus.append(a[i])

if not plus and k % 2 == 1:
    minus.sort(reverse=True)
    for i in range(k):
        ans *= minus[i]
        ans %= mod
    print(ans)
    exit()

plus.sort(reverse=True)
minus.sort()
plus = deque(plus)
minus = deque(minus)

cou = []
while True:
    if len(cou) == k:
        break
    elif len(cou) == k-1:
        cou.append(plus.popleft())
        break
    else:
        if len(plus)>=2 and len(minus)>=2:
            p1 = plus.popleft()
            p2 = plus.popleft()
            m1 = minus.popleft()
            m2 = minus.popleft()
            if p1*p2 > m1*m2:
                cou.append(p1)
                plus.appendleft(p2)
                minus.appendleft(m2)
                minus.appendleft(m1)
            else:
                cou.append(m1)
                cou.append(m2)
                plus.appendleft(p2)
                plus.appendleft(p1)
        elif len(plus) < 2:
            m1 = minus.popleft()
            m2 = minus.popleft()
            cou.append(m1)
            cou.append(m2)
        elif len(minus) < 2:
            p1 = plus.popleft()
            cou.append(p1)

        
for i in cou:
    ans *= i
    ans %= mod
print(ans)
10
ZABCDBABCQ

### FIXED CODE ###

K, X = [int(i) for i in input().split()]
print("Yes" if 500*K>=X else "No")
def dfs(v, parent):
    for edge in adj[v]:
        if edge[0] == parent:
            continue
        dist[edge[0]] = dist[v] + edge[1]
        dfs(edge[0], v)


n = int(input())
adj = [[] for i in range(n + 1)]
for i in range(n - 1):
    a, b, c = [int(x) for x in input().split()]
    adj[a].append((b, c))
    adj[b].append((a, c))
q, k = [int(x) for x in input().split()]
dist = [0] * (n + 1)
dfs(k, k)
for j in range(q):
    l, r = [int(x) for x in input().split()]
    print(dist[l] + dist[r])
# print(*data, sep='\n')


### FIXED CODE ###

import sys
import collections

n = int(input())
adj = [[] for i in range(n + 1)]
for i in range(n - 1):
    a, b, c = [int(x) for x in input().split()]
    adj[a].append((b, c))
    adj[b].append((a, c))
q, k = [int(x) for x in input().split()]
dist = [0] * (n + 1)
queue = collections.deque()
queue.append(k)
while len(queue) > 0:
    u = queue.popleft()
    for v, weight in adj[u]:
        if dist[v] == 0:
            queue.append(v)
            dist[v] = dist[u] + weight
for j in range(q):
    l, r = [int(x) for x in input().split()]
    print(dist[l] + dist[r])
# print(*data, sep='\n')
import sys

class Node():
    __slots__ = ['key', 'left', 'right']
    def __init__(self, key):
        self.key = key
        self.left, self.right = None

root = None
def insert(z):
    global root
    x, y = root, None
    while x:
        y = x
        if z < x.key:
            x = x.left
        else:
            x = x.right
    
    if y == -1:
        root = Node(z)
    elif z < y.key:
        y.left = Node(z)
    else:
        y.right = Node(z)
        
def preorder(x):
    return f" {x.key}" + preorder(x.left) + preorder(x.right) if x else ""

def inorder(x):
    return inorder(x.left) + f" {x.key}" + inorder(x.right) if x else ""
        
input()
node = {}
root = -1
for s in sys.stdin:
    if s[0] == "p":
        print(inorder(root))
        print(preorder(root))
    else:
        insert(node, int(s[7:]))



### FIXED CODE ###

import sys

class Node():
    __slots__ = ['key', 'left', 'right']
    def __init__(self, key):
        self.key = key
        self.left, self.right = None, None
        
    def __str__(self):
        return self.key

root = None
def insert(z):
    global root
    x, y = root, None
    while x:
        y = x
        if z < x.key:
            x = x.left
        else:
            x = x.right
    
    if y == None:
        root = Node(z)
    elif z < y.key:
        y.left = Node(z)
    else:
        y.right = Node(z)
        
def preorder(x):
    return f" {x.key}" + preorder(x.left) + preorder(x.right) if x else ""

def inorder(x):
    return inorder(x.left) + f" {x.key}" + inorder(x.right) if x else ""
        
input()
node = {}
for s in sys.stdin:
    if s[0] == "p":
        pass
        print(inorder(root))
        print(preorder(root))
    else:
        insert(int(s[7:]))
S = list(map(int, input()))

i  = 1
counter = 0
length = len(S)
while i < length or length < 2:
	if S[i - 1] != S[i]:
		del(S[i - 1 : i + 1])
		counter += 1
		length -= 2
		i -= 1
	else:
		i += 1
		
print(counter * 2)

### FIXED CODE ###

S = list(map(int, input()))

print(min(S.count(0), S.count(1)) * 2)
N = int(input())
cards = list(map(int, input().split()))
cards.reverse() 
print(cards[0::2]-cards[1::2])

### FIXED CODE ###

N = int(input())
cards = list(map(int, input().split()))
cards.sort(reverse=True) 
print(sum(cards[0::2])-sum(cards[1::2]))
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

N, K=LI()
A=LI()

counts = collections.Counter(A)
counts = counts.values()
counts = sorted(counts, reverse=True)
result = 0
while len(counts) != K:
    result=counts.pop()
    
print(result)
    

### FIXED CODE ###

import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

N, K=LI()
A=LI()

counts = collections.Counter(A)
counts = counts.values()
counts = sorted(counts, reverse=True)
result = 0
while len(counts) > K:
    result+=counts.pop()
    
print(result)
n,m=map(int,input().split())
l=list(map(int,input().split()))
d=sum(l)
if n>l:
    print("No")
else:
    print("Yes")

### FIXED CODE ###

n,m=map(int,input().split())
l=list(map(int,input().split()))
d=sum(l)
if n>d:
    print("No")
else:
    print("Yes")
from collections import defaultdict

N = int(input())
edges = [list(map(int, input().split())) for _ in range(N - 1)]
Q, K = map(int, input().split())

graph = defaultdict(set)
for v, w, c in edges:
    graph[v].add((w, c))
    graph[w].add((v, c))

INF = 10 ** 9 + 7
dp = [INF] * (N + 1)
visited = [False] * (N + 1)

def dfs(v, p, d):    
    dp[v] = d
    visited[v] = True
    for j, c in graph[v]:
        if j == p:
            continue
        dfs(j, v, d + c)

dfs(K, 0, 0)

for _ in range(Q):
    x, y = map(int, input().split())
    print(dp[x] + dp[y])


### FIXED CODE ###

from collections import defaultdict
from heapq import heappop, heappush

N = int(input())
edges = [list(map(int, input().split())) for _ in range(N - 1)]
Q, K = map(int, input().split())

graph = defaultdict(set)
for v, w, c in edges:
    graph[v].add((w, c))
    graph[w].add((v, c))

dp = [-1] * (N + 1)
pq = []

# Initialization
dp[K] = 0
heappush(pq, (0, K))

while pq:
    cost, u = heappop(pq)
    
    for w, c in graph[u]:
        if dp[w] > -1:
            continue

        dp[w] = dp[u] + c
        heappush(pq, (dp[w], w))

for _ in range(Q):
    x, y = map(int, input().split())
    print(dp[x] + dp[y])
N, M = map(int, input().split())

from collections import defaultdict

G = defaultdict(set)


results = [-1]*N
flags   = [False]*N

for _ in range(M):
    A, B = map(int, input().split())
    G[A-1].add(B-1)
    G[B-1].add(A-1)

#print(G)

### 最初の段階は、全て繋がっているかどうか。
seen = [False]*N
def rec(i):
    seen[i] = True
    for j in G[i]:
        if seen[j]:
            continue
        rec(j)

for i in range(N):
    if seen[i]:
        continue
    rec(i)

#print(seen)
#全て繋がっているなら、whileループを実装して良い
if sum(seen) != N:
    print('No')
else:
    searchs = set(range(1,N))
    for i in list(searchs):
        if 0 in G[i]:
            results[i] = 0
            flags[i]   = True
            searchs.remove(i)
    while len(searchs) != 0:
        for i in list(searchs):
            for j in G[i]:
                if flags[j] == True:
                    results[i] = j
                    searchs.remove(i)
                    break

    print('Yes')
    for i,v in enumerate(results[1:]):
        print(f'{v+1}')


### FIXED CODE ###

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

from collections import defaultdict, deque

G = defaultdict(set)


results = [-1]*N
flags   = [False]*N

for _ in range(M):
    A, B = map(int, input().split())
    G[A-1].add(B-1)
    G[B-1].add(A-1)

seen    = [False]*N
partner = [0]*N

q = deque([0])
seen[0] = True


while q:
    now = q.popleft()
    for i in G[now]:
        if seen[i]:
            continue
        seen[i] = True
        partner[i] = now
        q.append(i)

if len(seen) != N:
    print('No')
else:
    print('Yes')
    for i in partner[1:]:
        print(i+1)
from collections import deque
from collections import defaultdict

n, m = map(int, input().split())
g = defaultdict(list)
s = set(list(range(1, n+1)))
ans = 0

for i in range(m):
    a, b = map(int, input().split())
    g[a].append(b)
    
while s:
    root = s.pop()
    q = deque()
    q.append(root)
    done = set()
    done.add(root)

    while q:
        node = q.popleft()
        
        for adj in g[node]:
            if adj not in done:
                done.add(adj)
                q.append(adj)
                s.remove(adj)
    ans += 1

print(ans - 1)


### FIXED CODE ###

from collections import deque
from collections import defaultdict

n, m = map(int, input().split())
g = defaultdict(list)
s = set(list(range(1, n+1)))
ans = 0

for i in range(m):
    a, b = map(int, input().split())
    g[a].append(b)
    g[b].append(a)

while s:
    root = s.pop()
    q = deque()
    q.append(root)
    done = set()
    done.add(root)

    while q:
        node = q.popleft()

        for adj in g[node]:
            if adj not in done:
                done.add(adj)
                q.append(adj)
                s.remove(adj)
    ans += 1

print(ans - 1)
n,k=map(int,input().split())
A=[int(i) for i in input().split()]


def f(i):
    if i<0: return True
    if i>= 10**9: return False
    x = sum([(a-1)//i for a in A])
    if x<=k:
        return True
    else:
        return False
l=-1
r=10**9
while r-l>1:
    m = (l+r)//2
    if f(m):
        r=m
    else:
        l=m
    #print(l,m,r)
print(r)

### FIXED CODE ###

n,k=map(int,input().split())
A=[int(i) for i in input().split()]


def f(i):
    if i<=0: return False
    if i>= 10**9: return True
    x = sum([(a-1)//i for a in A])
    if x<=k:
        return True
    else:
        return False
l=-1
r=10**9
while r-l>1:
    m = (l+r)//2
    if f(m):
        r=m
    else:
        l=m
    #print(l,m,r)
print(r)
from bisect import bisect

N = int(input())
a = list(map(int,input().split()))
g = [[] for _ in range(N)]
for i in range(N-1):
    u,v = map(int,input().split())
    u -= 1
    v -= 1
    g[u].append(v)
    g[v].append(u)

ans = [0]*N
def dfs(t,f,l,seq):
    l = l.copy()
    seq = seq.copy()
    l.append(a[t])
    print(l,seq)
    i = bisect(seq,l[-1])
    if len(seq)==i:
        seq.append(l[-1])
    else:
        seq[i]=l[-1]
    ans[t] = len(seq)
    for v in g[t]:
        if v != f:
            dfs(v,t,l,seq)
dfs(0,0,[],[])
for i in range(N):
    print(ans[i])



### FIXED CODE ###

from bisect import bisect_left as bisect
import sys
sys.setrecursionlimit(10**9)

N = int(input())
a = list(map(int,input().split()))
g = [[] for _ in range(N)]
for i in range(N-1):
    u,v = map(int,input().split())
    u -= 1
    v -= 1
    g[u].append(v)
    g[v].append(u)

ans = [0]*N
def dfs(t,f,l):
    res = 0
    i = bisect(l,a[t])
    if len(l)==i:
        l.append(a[t])
    else:
        res = [i,l[i]]
        l[i]=a[t]
    ans[t] = len(l)
    for v in g[t]:
        if v != f:
            back = dfs(v,t,l)
            if back:
                l[back[0]] = back[1]
            else:
                l.pop()
    return res
dfs(0,0,[])
for i in range(N):
    print(ans[i])
if '7' in N:
  print("Yes")
else:
  print("No")  

### FIXED CODE ###

N = input()
if '7' in str(N):
  print("Yes")
else:
  print("No")
first_line = input().split()
second_line = input().split()
third_line = input().split()
 
first_line = [int(i) for i in first_line]
second_line = [int(i) for i in second_line]
third_line = [int(i) for i in third_line]

N = input()
N = int(N)
B  = [] 
for i in range(N):
    inp  =input()
    inp = int(inp)
    B.append(inp)


# arr = [[0]*3]*3
# print(arr)
# for i in range(3):
#     arr[0][i]= first_line[i]
#     print(arr)
# print(arr)
# for i in range(3):
#     arr[1][i]= second_line[i]
# for i in range(3):
#     arr[2][i]= third_line[i]

arr = []
arr.append(first_line)
arr.append(second_line)
arr.append(third_line)
carr = [[False for i in range(3)] for j in range(3)]

for b in B:
    for i in range(3):
        for j  in range(3):
            if b == arr[i][j]:
                carr[i][j] = True

def yoko(carr):
    for i in range(3):
        flag = 0
        for j in range(3):
            if carr[i][j] != True:
                flag = 1
        if flag == 0 :
            return True    
    return False


def tate(carr):
    for i in range(3):
        flag = 0
        for j in range(3):
            if carr[j][i] != True:
                flag = 1
                break
        if flag == 0:

            return  True
    
    return False

def naname (carr):
    flag2 = 0
    flag1 = 0
    for i in range(3):
        if carr[i][i] != True:
            flag1 = 1

        if carr[i][3-i-1] != True:
            flag2 = 1;
    if flag1==0 or flag2 ==0:
        return True
    else:
        return False

def checker(carr):
    # print(tate(carr))
    # print(yoko(carr))
    # print(naname(carr))
    
    if not tate(carr)  and not yoko(carr) and not naname(carr):
        return 'No'
    else:
        return 'Yes' 
print(checker(carr))

### FIXED CODE ###

N = input()
N = int(N)
if N%2 ==0:
    amari = 0
else:
    amari = 1

N  = N/2
N = int(N)

print(N+ amari)
a = int(input())
b = int(input())
if ((a*b)%2):
    print('Odd')
else:
    print('Even')

### FIXED CODE ###

a,b= (int(i) for i in input().split())
if ((a*b)%2):
    print('Odd')
else:
    print('Even')
s1 = input()
l = input()
l1 = len(l)
s = s1*10000
#print(s)
sa = set(s1)
la = set(l)
if la.issubset(sa):
    j,su = 0,0
    for i in s:
        if i == l[j]:
            j+=1
        su+=1
        if j>=l1: break;
    print(su)
else:
    print(-1)

### FIXED CODE ###

s = input()
l = input()
     
count = 0
ind = -1
if set(l).issubset(set(s)):
    for i in range(len(l)):
        ind = s.find(l[i], ind+1)
        if ind == -1:
            count += 1
            ind = s.find(l[i], ind+1)
    print(count*len(s) + ind+1)
 
else:
    print(-1)
H, W = map(int, input().split())
    if H == 1 or W == 1:
        print("1")
    elif H%2 == 1 and W%2 == 1:
        print((H-1)*(W-1)//2+(H-1)//2+(W-1)//2+1)
    elif H%2 == 1 and W%2 == 0:
        print((H-1)*W//2+W//2)
    elif H%2 == 0 and W%2 == 1:
        print(H*(W-1)//2+H//2)
    else:
        print(H*W//2)
resolve()

### FIXED CODE ###

def resolve():
    H, W = map(int, input().split())
    if H == 1 or W == 1:
        print("1")
    elif H%2 == 1 and W%2 == 1:
        print((H-1)*(W-1)//2+(H-1)//2+(W-1)//2+1)
    elif H%2 == 1 and W%2 == 0:
        print((H-1)*W//2+W//2)
    elif H%2 == 0 and W%2 == 1:
        print(H*(W-1)//2+H//2)
    else:
        print(H*W//2)
resolve()
import sys
import pprint

pp = pprint.PrettyPrinter(indent=4)

def main():
    """ Code implementation """
    a, b = map(int, raw_input().split())
    if b % a == 0:
        print(b + a)
    else:
        print(b - a)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
import pprint

pp = pprint.PrettyPrinter(indent=4)

def main():
    """ Code implementation """
    a, b = map(int, input().split())
    if b % a == 0:
        print(b + a)
    else:
        print(b - a)

if __name__ == '__main__':
    main()
N, M = map(int, input().split())
 
a = 0
for i in range(M):
  b = int(input())
  a += b

day_count = N-a

if day_count>=0:
  print(day)
else:
  print(-1)

### FIXED CODE ###

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

c = list(map(int,input().split()))
c_sum = sum(c)

day_count = N-c_sum

if day_count>=0:
  print(day_count)
else:
  print(-1)
n = int(input())
a = list(map(int,input()))
b = list(map(int,input()))
c = list(map(int,input()))

ans = 0
for i in range(n):
  ans += b[a[i]-1]
  if i != n-1 and a[i+1]-a[i] == 1:
    ans += c[a[i]-1]
print(ans)

### FIXED CODE ###

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

ans = 0
for i in range(n):
  ans += b[a[i]-1]
  if i != n-1 and a[i+1]-a[i] == 1:
    ans += c[a[i]-1]
print(ans)
import utility

n,m = map(int, input().split(" "))

result = 0
if(n >=1):
    result = result + n*(n-1)/2

if(m >=1):
    result = result + m*(m-1)/2

print(int(result))

### FIXED CODE ###

n,m = map(int, input().split(" "))

result = 0
if(n >=1):
    result = result + n*(n-1)/2

if(m >=1):
    result = result + m*(m-1)/2

print(int(result))
dxy = [[1,0],[0,1],[-1,0],[0,-1],[1,1],[-1,1],[-1,-1],[1,-1]]
def solve(w,h):
	if 0 <= w < W and 0 <= h < H and field[h][w] == 1:
		field[h][w] = 0
		for dx,dy in dxy:
			solve(w+dx,h+dy)

while 1:
	W,H = map(int,raw_input().split())
	if W == 0: break
	field = [map(int,raw_input().split()) for i in range(H)]
	ans = 0
	for h in range(H):
		for w in range(W):
			if field[h][w] == 1:
				solve(w,h)
				ans += 1
	print ans

### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)

def dfs(x, y):
    C[y][x] = 0
    for dx,dy in zip([1,1,0,-1,-1,-1,0,1],[0,1,1,1,0,-1,-1,-1]):
        if 0 <= x+dx < w and 0 <= y+dy < h and C[y+dy][x+dx] == 1:
            dfs(x+dx, y+dy)

while 1:
    w,h = map(int,raw_input().split())
    if w == h == 0: break
    C = [map(int,raw_input().split()) for _ in xrange(h)]

    ans = 0
    for y in range(h):
        for x in range(w):
            if C[y][x] == 1:
                dfs(x, y)
                ans += 1
    print ans
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = input()
print(a[k-1])

### FIXED CODE ###

k = int(input())
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(a[k-1])
N,M = list(map(int,input().split()))
xarray = list(map(int,input().split()))
diff = []
for i in range(len(xarray)-1):
    diff.append(abs(xarray[i+1]-xarray[i]))

if len(diff) == 0:
    print(0)
else:
    diff2 = sorted(diff, reverse = True)
    for j in range(N):
        diff2[j] = 0
    print(sum(diff2))

### FIXED CODE ###

N,M = list(map(int,input().split()))
xarray = sorted(list(map(int,input().split())))
 
diff = []
if len(xarray) == 1:
    print(0)
elif N >= M:
    print(0)
else:
    for i in range(len(xarray)-1):
        diff.append(abs(xarray[i+1]-xarray[i]))
 
    if len(diff) == 0:
        print(0)
    else:
        diff2 = sorted(diff, reverse = True)
        
 
        if N == 1:
            
            print(sum(diff2))
        else:
            for j in range(N-1):
                diff2[j] = 0
            
            print(sum(diff2))
import sys
# from collections import defaultdict
# from collections import Counter
# from queue import Queue
import math

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

    As = [int(s) for s in input().split()]
    logsum = 0
    prod = 1
    for a in As:
        logsum += math.log10(a)
        prod *= a

    if logsum > 18:
        print('-1')
        return

    print(prod)

    # As = []
    # for i in range(N):
    #     tmp = int(input())
    #     As.append(tmp)

    return 0

if __name__ == '__main__':
    sys.exit(main())


### FIXED CODE ###

import sys
# from collections import defaultdict
# from collections import Counter
# from queue import Queue
import math

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

    As = [int(s) for s in input().split()]
    logsum = 0
    prod = 1
    for a in As:
        if a == 0:
            print('0')
            return

        logsum += math.log10(a)
        # sys.stderr.write('{}\n'.format(logsum))


    if logsum > 18.2:
        print('-1')
        return

    for a in As:
        prod *= a

    if prod > 10 ** 18:
        print('-1')
        return
    print(prod)

    # As = []
    # for i in range(N):
    #     tmp = int(input())
    #     As.append(tmp)

    return 0

if __name__ == '__main__':
    sys.exit(main())
A,B=[int(x) for x in input().split()]

m=B%A

if m == 0:
  print(A+B)
else:
  prince(B-A)

### FIXED CODE ###

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

if B%A==0:
  print(A+B)
else:
  print(B-A)
a, x, b = input().split()
c = int(a)
d = int(b)
if x == ("+"):
  print (c + d)
elif op == ("-"):
  print (c - d)

### FIXED CODE ###

a, x, b = input().split()
c = int(a)
d = int(b)
if x == ("+"):
  print (c + d)
elif x == ("-"):
  print (c - d)