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

import bisect
n, k = map(int, input().split())

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

a = sorted(a)
f = sorted(f, reverse=True)

score = sorted(((x * y, x, y) for (x, y) in zip(a, f)))
for _ in range(k):
    p, x, y = score.pop()
    if x > 0:
        x -= 1
    bisect.insort(score, (x * y, x, y))

p, _, _ = score.pop()
print(p)




### FIXED CODE ###

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

a = map(int, input().split())
f = map(int, input().split())

a = sorted(a)
f = sorted(f, reverse=True)

def judge(n):
    s = 0
    for x, y in zip(a, f):
        s += max(0, x - n // y)
    if s <= k:
        return True
    else:
        return False

low = 0
high = a[-1] * f[0]
while high - low > 0:
    mid = (high + low) // 2
    if judge(mid):
        high = mid
    else:
        low = mid + 1
print(high)
### BUGGY CODE ###

n, k = map(int, input().split())
p =[int(s) for s in input().split()]
s = 0
key = 0
pred = 0
for r in range(n-k+1):
    s2 = sum(p[r:r+k])
    if s2>s:
        s = s2
        key = r
print(0.5*(s+k))

### FIXED CODE ###

n, k = map(int, input().split())
p =[int(s) for s in input().split()]
s = 0
key = 0
pred = 0
acc = {}
for h in range(n):
    if h == 0:
        acc[0] = p[0]
    else:
        acc[h] = acc[h-1]+p[h]
for r in range(n-k+1):
    if r == 0:
        s2 = acc[k-1]
    else:
        s2 = acc[k+r-1]-acc[r-1]
    if s2>s:
        s = s2
        key = r
print(0.5*(s+k))
### BUGGY CODE ###

def merge(a_list, b_list):
    res = []

    while len(a_list) > 0 and len(b_list) > 0:
        if a_list[0] > b_list[0]:
            res.append(a_list.pop(0))
        else:
            res.append((b_list.pop(0)))

    if len(a_list) > 0:
        res.extend(a_list)
    if len(b_list) > 0:
        res.extend(b_list)

    return res


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

score_list = [[] for i in range(M+1)]


for ab in ab_list:
    if ab[0] <= M:
        score_list[ab[0]].append(ab[1])
for i in range(len(score_list)):
    score_list[i].sort(reverse=True)

ans = 0
for i in range(0, M+1):
    if len(score_list[i]) == 0:
        continue
    ans += score_list[i].pop(0)
    if i < M and len(score_list[i]) > 0:
        score_list[i+1] = merge(score_list[i], score_list[i+1])

print(ans)

### FIXED CODE ###

import heapq


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

score_list = [[] for i in range(M+1)]


for ab in ab_list:
    if ab[0] <= M:
        score_list[ab[0]].append(ab[1])


ans = 0
candidates = []

for i in range(0, M+1):

    for s in score_list[i]:
        heapq.heappush(candidates, -s)
    if len(candidates) == 0:
        continue
    ans -= heapq.heappop(candidates)


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

#!/usr/bin/env python3

class Bit:
    # Binary Indexed Tree
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def __iter__(self):
        psum = 0
        for i in range(self.size):
            csum = self.sum(i + 1)
            yield csum - psum
            psum = csum
        raise StopIteration()

    def __str__(self):  # O(nlogn)
        return str(list(self))

    def sum(self, i):
        # [0, i) の要素の総和を返す
        if not (0 <= i <= self.size): raise ValueError("error!")
        s = 0
        while i>0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        if not (0 <= i < self.size): raise ValueError("error!")
        i += 1
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

    def __getitem__(self, key):
        if not (0 <= key < self.size): raise IndexError("error!")
        return self.sum(key+1) - self.sum(key)

    def __setitem__(self, key, value):
        # 足し算と引き算にはaddを使うべき
        if not (0 <= key < self.size): raise IndexError("error!")
        self.add(key, value - self[key])

(n,), (s,), _, *q = map(str.split, open(0))
*s, = s
BIT = [Bit(int(n)) for _ in [0] * 26]
for e, t in enumerate(s):
    BIT[ord(t) - 97].add(e, 1)
for a, b, c in q:
    if a == "1":
        i = int(b)
        BIT[ord(s[i - 1]) - 97].add(i - 1, -1)
        s[i - 1] = c
        BIT[ord(c) - 97].add(i - 1, 1)
    else:
        l, r = int(b), int(c)
        print(sum(BIT[i].sum(r) - BIT[i].sum(l - 1) > 0 for i in range(26)))

### FIXED CODE ###

#!/usr/bin/env python3

class Bit:
    # Binary Indexed Tree
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def __iter__(self):
        psum = 0
        for i in range(self.size):
            csum = self.sum(i + 1)
            yield csum - psum
            psum = csum
        raise StopIteration()

    def __str__(self):  # O(nlogn)
        return str(list(self))

    def sum(self, i):
        # [0, i) の要素の総和を返す
        if not (0 <= i <= self.size): raise ValueError("error!")
        s = 0
        while i>0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        if not (0 <= i < self.size): raise ValueError("error!")
        i += 1
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

    def __getitem__(self, key):
        if not (0 <= key < self.size): raise IndexError("error!")
        return self.sum(key+1) - self.sum(key)

    def __setitem__(self, key, value):
        # 足し算と引き算にはaddを使うべき
        if not (0 <= key < self.size): raise IndexError("error!")
        self.add(key, value - self[key])

(n,), (s,), _, *q = map(str.split, open(0))
*s, = s
BIT = [Bit(int(n)) for _ in [0] * 26]
for e, t in enumerate(s):
    BIT[ord(t) - 97].add(e, 1)
for a, b, c in q:
    if a == "1":
        i = int(b)
        BIT[ord(s[i - 1]) - 97].add(i - 1, -1)
        s[i - 1] = c
        BIT[ord(c) - 97].add(i - 1, 1)
    else:
        l, r = int(b), int(c)
        print(sum(BIT[i].sum(r) - BIT[i].sum(l - 1) > 0 for i in range(26)))
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=0
a.sort()
b.sort()
c.sort()
for i in range(n):
    ans+=sum(x<b[i] for x in a)*sum(y>b[i] for y in c)
print(ans)

### FIXED CODE ###

import bisect
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=0
a.sort()
b.sort()
c.sort()
for i in range(n):
    ans+=bisect.bisect_left(a,b[i])*(n-bisect.bisect_right(c,b[i]))
print(ans)
### BUGGY CODE ###

n=int(input())
a=[]
for i in range(n):
    k=int(input())
    if k not in a:
        a.append(k)
    elif k in a:
        a.remove(k)
print(len(a))

### FIXED CODE ###

n=int(input())
a=sorted([int(input()) for _ in range(n)])

ptr=0
res=0
while ptr<n:
    cc=a[ptr]
    f=0
    while ptr<n and a[ptr]==cc: #出現回数をカウント
        f+=1
        ptr+=1
    res+=f%2 #奇数回の場合インクリメント
print(res)
### BUGGY CODE ###

# Hello World program in Python
    
n = int(input())
lst = list(map(int, input().split()))
ans = 1
for a in lst: 
    ans *= a
if(ans>1000000000000000000): 
    print(-1)
else:
    print(ans)

### FIXED CODE ###

n = int(input())
lst = list(map(int, input().split()))
lst.sort()
ans = 1
for a in lst: 
    ans *= a
    if ans > 1e18:
        print(-1)
        break
else:
    print(ans)
### BUGGY CODE ###

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

c= 0
for i in range(1,int(input())):
    c+=len(make_divisors(i))
print(c)

### FIXED CODE ###

n = int(input())
c = 0
for i in range(1,n):
    c+=(n-1)//i
print(c)
### BUGGY CODE ###

from collections import deque

N, M, K = map(int, input().split())
A = deque(map(int, input().split()))
B = deque(map(int, input().split()))

result = 0

a, b = 0, 0
na, nb = 0, 0
for i in range(len(A)):
    if a+A[i] <= K:
        a += A[i]
        na += 1
    else:
        break
for i in range(len(B)):
    if b+B[i] <= K:
        b += B[i]
        nb += 1
    else:
        break

while A != deque() and K >= A[0]:
    if na > nb:
        result += 1
        na -= 1
        K -= A.popleft()
    elif na == nb:
        result += 1
        if A[0] <= B[0]:
            na -= 1
            K -= A.popleft()

while B != deque() and K >= B[0]:
    if na < nb:
        result += 1
        nb -= 1
        K -= B.popleft()
    elif na == nb:
        result += 1
        if A[0] > B[0]:
            nb -= 1
            K -= B.popleft()

print(result)


### FIXED CODE ###

from itertools import accumulate

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0

a_accum = [0] + list(accumulate(a))
b_accum = [0] + list(accumulate(b))

j = m
for i in range(n+1):
  while k < a_accum[i] + b_accum[j] and j >= 1:
    j -= 1
  if k >= a_accum[i] + b_accum[j] and ans < i + j:
    ans = i + j

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

MOD=1000000007
n,m=map(int,input().split())

S=[int(_) for _ in input().split()]
T=[int(_) for _ in input().split()]

dp=[[0 for j in range(m+1)] for i in range(n+1)]
for i in range(n+1):
  dp[i][0]=1
for j in range(m+1):
  dp[0][j]=1

for i in range(n):
    for j in range(m):
        if S[i]!=T[j]:
            dp[i+1][j+1]=dp[i+1][j]+dp[i][j+1]-dp[i][j]
            dp[i+1][j+1]%=MOD
        else:
            dp[i+1][j+1]=dp[i+1][j]+dp[i][j+1]
            dp[i+1][j+1]%=MOD
print((dp[n][m])%MOD)

### FIXED CODE ###

MOD=1000000007
n,m=map(int,input().split())

S=[int(_) for _ in input().split()]
T=[int(_) for _ in input().split()]

dp=[[0 for j in range(m+1)] for i in range(n+1)]
for i in range(n+1):
  dp[i][0]=1
for j in range(m+1):
  dp[0][j]=1

for i in range(n):
    for j in range(m):
        if S[i]!=T[j]:
            dp[i+1][j+1]=dp[i+1][j]+dp[i][j+1]-dp[i][j]
            dp[i+1][j+1]%=MOD
        else:
            dp[i+1][j+1]=dp[i+1][j]+dp[i][j+1]
            dp[i+1][j+1]%=MOD
print((dp[n][m])%MOD)
### BUGGY CODE ###

n = int(input())
s = list(map(int,input().split()))
n = int(input())
t = list(map(int,input().split()))
count = 0

def binarySearch(a,b):
    left = 0
    right = len(b)
    while left < right:
        middle = (left + right)//2
        
        if b[middle] == a:
            return 1
        elif b[middle] < a:
            left = middle -1
        elif b[middle] > a:
            right = middle 
    return 0

            
for a in t:
    count += binarySearch(a, s)

print(count)

### FIXED CODE ###

input()
S = list(map(int,input().split()))
input()
T = list(map(int,input().split()))

def binarySearch(k,a):
    left = 0
    right = len(a)
    while left < right:
        middle = (left + right) // 2
        if a[middle] == k:
            return 1
        elif a[middle] < k:
            left = middle+1
        elif a[middle] > k:
            right = middle 
    return 0


count = 0
for t in T:
    count += binarySearch(t,S)
print(count)
### BUGGY CODE ###

a, b, c, k = map(int, input().split())
ans = 0
if a >= k:
    ans = k
    k = 0
else:
    k -= a
    ans = a
while k > 0:
    k -= 1
    if b > 0:
        b -= 1
    else:
        c -= 1
        ans -= 1
print(ans)

### FIXED CODE ###

a, b, c, k = map(int, input().split())
ans = 0
if a >= k:
    ans = k
    k = 0
else:
    k -= a
    ans = a
k -= b
if k > 0:
    ans -= k
print(ans)
### BUGGY CODE ###

h,w,d = map(int,input().split())
a = [[int(i) for i in input().split()] for _ in range(h)]
q = int(input())
l = [0]*q ;r = [0]*q
for i in range(q): l[i],r[i] = map(int,input().split())
dct = {}

for i in range(h):
    for j in range(w):
        dct[a[i][j]] = (i,j)
    
for i in range(q):
    ans = 0
    n = l[i]
    cx,cy = dct[n]
    while dct[n] != dct[r[i]]:
        n += d
        nx,ny = dct[n]
        ans += abs(nx-cx)+abs(ny-cy)
        cx,cy = nx,ny
    print(ans)

### FIXED CODE ###

h,w,D = map(int,input().split())
a = [[int(i) for i in input().split()] for _ in range(h)]
px = [0]*(h*w+1)
py = [0]*(h*w+1)
d = [0]*(h*w+1)

for i in range(h):
    for j in range(w):
        px[a[i][j]] = i
        py[a[i][j]] = j

for i in range(D+1,h*w+1):
    d[i] = d[i-D] + abs(px[i]-px[i-D]) + abs(py[i]-py[i-D])

q = int(input())
for _ in range(q):
    l,r = map(int,input().split())
    print(d[r]-d[l])
### BUGGY CODE ###

import queue
H, W = map(int, input().split())
S = [list(input()) for h in range(H)]
 
Search = [(-1, 0), (0, -1), (1, 0), (0, 1)]
Total = 0
Visited = [[False for w in range(W)] for h in range(H)]
for h in range(H):
    for w in range(W):
        if not Visited[h][w]:
            Visited[h][w] = True
            if S[h][w] == ".": Black, White = 0, 1
            else: Black, White = 1, 0
            Q = queue.Queue()
            Q.put((h, w))
            while not Q.empty():
                now = Q.get()
                nh, nw = now[0], now[1]
                for s in Search:
                    nexth, nextw = nh + s[0], nw + s[1]
                    if 0 <= nexth < H and 0 <= nextw < W:
                        if not Visited[nexth][nextw] and S[nexth][nextw] != S[nh][nw]:
                            Visited[nexth][nextw] = True
                            Q.put((nexth, nextw))
                            if S[nexth][nextw] == ".": White += 1
                            else: Black += 1
            Total += Black * White

print(Total)

### FIXED CODE ###

import queue
H, W = map(int, input().split())
S = [list(map(int, input().replace(".", "0").replace("#","1"))) for h in range(H)]

Search = [(-1, 0), (0, -1), (1, 0), (0, 1)]
Total = 0
Visited = [[False for w in range(W)] for h in range(H)]
for h in range(H):
    for w in range(W):
        if not Visited[h][w]:
            Visited[h][w] = True
            Color = ([1, 0] if S[h][w] == 0 else [0, 1])
            Q = queue.Queue()
            Q.put((h, w, S[h][w]))
            while not Q.empty():
                nh, nw, nc = Q.get()
                for s in Search:
                    nexth, nextw = nh + s[0], nw + s[1]
                    if 0 <= nexth < H and 0 <= nextw < W:
                        if not Visited[nexth][nextw] and S[nexth][nextw] != nc:
                            nextc = S[nexth][nextw]
                            Visited[nexth][nextw] = True
                            Q.put((nexth, nextw, nextc))
                            Color[nextc] += 1
            Total += Color[0] * Color[1]

print(Total)
### BUGGY CODE ###

N, K, Q = map(int, input().split())
A = [int(input()) for _ in range(Q)]

points = [K for _ in range(N)]

for i in range(Q):
    points[A[i] - 1] += 1
    for j in range(N):
        points[j] -= 1

for j in range(N):
    if points[j] >= 1:
        print("Yes")
    else:
        print("No")


### FIXED CODE ###

N, K, Q = map(int, input().split())
A = [int(input()) for _ in range(Q)]

points = [K for _ in range(N)]

for i in range(Q):
    points[A[i] - 1] += 1

for j in range(N):
    points[j] -= Q

for j in range(N):
    if points[j] >= 1:
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

import heapq
import sys
input = sys.stdin.readline

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


class Dijkstra():
    class Edge():

        def __init__(self, _to, _cost):
            self.to = _to
            self.cost = _cost

    def __init__(self, V):

        self.G = [[] for i in range(V+1)]
        self._E = 0
        self._V = V

    def add(self, _from, _to, _cost):
        """ 2頂点と、辺のコストを追加"""
        self.G[_from].append(self.Edge(_to, _cost))
        self._E += 1

    def s_path(self, s):
        """ 始点sから頂点iまでの最短路リスト 
        """
        que = []
        heapq.heapify(que)
        d = [10**15] * (self._V+1)
        d[s] = 0
        heapq.heappush(que, (0, s))
        while que:
            cost, v = heapq.heappop(que)
            if d[v] < cost:
                continue

            for e in self.G[v]:
                if d[e.to] > d[v] + e.cost:
                    d[e.to] = d[v] + e.cost
                    heapq.heappush(que, (d[e.to], e.to))
        return d
      
      
graph_snuke = Dijkstra(N)
graph_yen = Dijkstra(N)
for _ in range(M):
    u, v, a, b = map(int, input().split())
    graph_yen.add(u, v, a)
    graph_yen.add(v, u, a)
    graph_snuke.add(u, v, b)
    graph_snuke.add(v, u, b)

yen = graph_yen.s_path(S)
snuke = graph_snuke.s_path(T)
minimum_case = [10**15 for i in range(N+1)]
for i in range(N):
    minimum_case[1+i] -= (yen[i+1]+snuke[i+1])
for i in range(N-1, -1, -1):
    minimum_case[i] = max(minimum_case[i], minimum_case[i+1])
for i in range(1, N+1):
    print(minimum_case[i])

### FIXED CODE ###

import sys
input=sys.stdin.readline
import heapq
def dijkstra(s,graph,n):
    dist=[float("inf") for i in range(n+1)]
    dist[s]=0
    pq=[]
    heapq.heapify(pq)
    heapq.heappush(pq,(0,s))
    while pq:
        mini_dis,node=heapq.heappop(pq)
        if dist[node]<mini_dis: continue
        for w,point in graph[node]:
            if dist[point]<w:continue
            newlen=dist[node]+w
            if newlen<dist[point]:
                heapq.heappush(pq,(newlen,point))
                dist[point]=newlen
    return dist
N,M,S,T=map(int,input().split())
graph_yen=[[] for i in range(N+1)]
graph_snuke=[[] for i in range(N+1)]
for _ in range(M):
    u,v,a,b=map(int,input().split())
    graph_yen[u].append((a,v))
    graph_yen[v].append((a,u))
    graph_snuke[u].append((b,v))
    graph_snuke[v].append((b,u))
    
yen=dijkstra(S,graph_yen,N)
snuke=dijkstra(T,graph_snuke,N)
minimum_case=[10**15 for i in range(N+1)]
for i in range(N):
    minimum_case[1+i]-=(yen[i+1]+snuke[i+1])
for i in range(N-1,-1,-1):
    minimum_case[i]=max(minimum_case[i],minimum_case[i+1])
for i in range(1,N+1):
    print(minimum_case[i])
### BUGGY CODE ###

import bisect


def make_divisors(n):
    lower_divisors, upper_divisors = set(), set()
    tmp = 1
    while tmp * tmp <= n:
        if n % tmp == 0:
            lower_divisors.add(tmp)
            if tmp != n // tmp:
                upper_divisors.add(n // tmp)
        tmp += 1
    return lower_divisors | upper_divisors


n = int(input())
*A, = map(int, input().split())
A.sort()
cnt = 0
for i, a in enumerate(A):
    if bisect.bisect_right(A, a) - bisect.bisect_left(A, a) != 1:
        cnt += 1
        continue
    X = make_divisors(a)
    for x in X:
        if x != a and bisect.bisect_right(
                A, x) - bisect.bisect_left(A, x) != 0:
            cnt += 1
            break
print(n - cnt)


### FIXED CODE ###

n = int(input())
*A, = map(int, input().split())
maxA = max(A)
# C[a] = A内のaの個数
C = {a: 0 for a in range(1, maxA + 1)}
for a in A:
    C[a] += 1
# D[a]=1: Aにaより小さいaの約数が存在する
D = {a: 0 for a in range(1, maxA + 1)}
for a in A:
    if C[a] > 0:
        tmp = 2
        while a * tmp <= maxA:
            D[a * tmp] = 1
            tmp += 1
ans = 0
for a in A:
    if C[a] == 1 and D[a] == 0:
        ans += 1
print(ans)
### BUGGY CODE ###

data = int(input())
ng_flag = False
min_value = 9999999
for i in range(1, data + 1):
    if data % i == 0:
        validation = i + data / i
        if validation < min_value:
            min_value = validation
print(int(min_value-2))

### FIXED CODE ###

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)
    return divisors

min_value = 1000000000000
data = int(input())
ng_flag = False
divisors_array = make_divisors(data)

if len(divisors_array) % 2 == 1:
    divisors_array.append(divisors_array[len(divisors_array)-1])
for i in range(0, len(divisors_array)):
    if(i % 2 == 0):
        first = divisors_array[i] -1 
        second = divisors_array[i+1] -1 
        if first + second < min_value:
            if i == 1:
                min_value = first + second
            else:
                min_value = first + second
print(min_value)
### BUGGY CODE ###

from functools import lru_cache

N,M = map(int,input().split())
B = list(map(lambda x: int(x)//2,input().split()))

@lru_cache(maxsize=1000)
def gcd(n,m):
    while n:
        m,n = [n,m%n]
    return m

su = 1
for b in B:
    su = su * b // gcd(su,b)

for b in B:
    if (su // b) % 2 == 0:
        print(0)
        exit()

print(M//su - M//(su*2))

### FIXED CODE ###

def a():
    N,M = map(int,input().split())
    B = list(map(lambda x: int(x)//2,input().split()))

    def gcd(n,m):
        while n:
            m,n = [n,m%n]
        return m

    su = 1
    for b in B:
        su *= b // gcd(su,b)
        if su > M:
            return 0

    for _ in filter(lambda x:(su//x)%2==0,B):
        return 0

    return M//su - M//(su*2)

print(a())
### BUGGY CODE ###

n = int(input())
g = [set() for _ in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    g[a-1].add(b-1)
    g[b-1].add(a-1)


def dfs(s, e, flag):
    visited = [-1]*n
    visited[0] = 0
    cnt = 1
    if flag: temp = [[s, [[0]]]]
    else: temp = [[s]]
    lst = []
    while temp:
        p = temp.pop()
        for a in g[p[0]]:
            if flag: q = p[1][:]
            if visited[a] != -1:continue
            visited[a] = visited[p[0]] + 1
            if flag: q.append([a])
            if a == e:
                lst = q[:]
                return lst
            if flag: temp.append([a, q])
            else: temp.append([a])
            cnt += 1
    return cnt

lst = dfs(0, n-1, True)

m = (len(lst) - 1) // 2
g[lst[m][0]].discard(lst[m+1][0])
g[lst[m+1][0]].discard(lst[m][0])

c0 = dfs(0, n-1, False)

if c0 > n - c0: print('Fennec')
else:print('Snuke')

### FIXED CODE ###

n = int(input())
g = [set() for _ in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    g[a-1].add(b-1)
    g[b-1].add(a-1)

def dfs(s):
    visited = [-1]*n
    visited[s] = 0
    temp = [s]
    lst = []
    while temp:
        p = temp.pop()
        for a in g[p]:
            if visited[a] != -1:continue
            visited[a] = visited[p] + 1
            temp.append(a)
    return visited

lst0 = dfs(0)
lstn = dfs(n-1)
cnt = 0
for i in range(n):
    if lst0[i] <= lstn[i]: cnt += 1

if cnt > n - cnt: print('Fennec')
else:print('Snuke')
### BUGGY CODE ###

#!/usr/bin/env python3
 
S = input()
T = input()
lenS = len(S)
lenT = len(T)
F1 = [False]*26
F2 = [False]*26
alpha = 'abcdefghijklmnopqrstuvwxyz'
for i in range(lenS):
    F1[alpha.index(S[i])] = True
for i in range(lenT):
    F2[alpha.index(T[i])] = True
for i in range(26):
    if not F1[i] and F2[i]:
        print(-1)
        exit()
 
ind = S.index(T[0])
ans = ind+1
for i in range(1,lenT):
    S = S[ind+1:] + S[:ind+1]
    ind = S.index(T[i])
    ans += ind+1
 
print(ans)

### FIXED CODE ###

import bisect
s = input().rstrip()
t = input().rstrip()

a_ord = ord("a")
ch_place = [[] for _ in range(26)]
for i, ch in enumerate(s):
    ch_place[ord(ch) - a_ord].append(i)

# print(ch_place)

count = 0
idx = -1 
for ch in t:
    ch_num = ord(ch) - a_ord
    if len(ch_place[ch_num]) == 0:
        print(-1)
        exit()
    place = bisect.bisect_right(ch_place[ch_num], idx)
    # print(ch_place[ch_num], idx, place)
    if place == len(ch_place[ch_num]):
        idx = ch_place[ch_num][0]
        count += 1
    else:
        idx = ch_place[ch_num][place]

# print(count, idx)
print(count * len(s) + idx + 1)
### BUGGY CODE ###

n = int(input())

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

count = 1

for i in a:
    count*=i

x = 10**18

if count > x:
    print(-1)
else:
    print(count)

### FIXED CODE ###

n = int(input())

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

count = 1

for i in range(n):
    count*=a[i]
    if count>10**18:
        print(-1)
        break

else:
    print(count)