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

# 未完成
import numpy as np
N = int(input())
x = np.zeros(N)
y = np.zeros(N)

for i in range(N):
    x[i], y[i] = map(int, input().split())


ans = 0
for m in range(N):
    for p in range(N):
        if m == p:
            continue
        diff_x = x[m] - x[p]
        diff_y = y[m] - y[p]
        ans_kari = 0
        for r in range(N):
            for q in range(N):
                if r == q:
                    continue
                if x[q] - x[r] == diff_x and y[q] - y[r] == diff_y:
                    ans_kari += 1
        if ans_kari > ans:
            ans = ans_kari

print("{}".format(int(N-ans)))


### FIXED CODE ###

# 未完成

import sys
N = int(input())
x = [0]*N
y = [0]*N
kouholist = []
ans = N
if N == 1:
    print(1)
    sys.exit()

for i in range(N):
    x[i], y[i] = map(int, input().split())
for m in range(N):
    for p in range(N):
        if m == p:
            continue
        diff_x = x[m] - x[p]
        diff_y = y[m] - y[p]
        ans_kari = N
        for r in range(N):
            for q in range(N):
                if x[q] - x[r] == diff_x and y[q] - y[r] == diff_y:
                    ans_kari -= 1
        if ans_kari < ans:
            ans = ans_kari

print("{}".format(ans))
### BUGGY CODE ###

s = input()
n = len(s)
t = ''
here = 0
er = 0
r = 0
flag = 1
while here < n:
  if s[here] == 'e' and here + 2 < n:
    if s[here:here+3] == 'era':
      t += 'erase'
      here += 5
      er = 0
      r = 1
    elif s[here] == 'e' and er == 1:
      t += 'er'
      here += 2
      er = 0
      r = 0
  elif s[here] == 'e' and er == 1:
    t += 'er'
    here += 2
    er = 0
    r = 0
  elif s[here] == 'd':
    t += 'dream'
    here += 5
    er = 1
    r = 0
  elif s[here] == 'r' and r == 1:
    t += 'r'
    here += 1
    er = 0
    r = 0
  else:
    flag = 0
    break
if s == t and flag == 1:
  print('YES')
else:
  print('NO')

### FIXED CODE ###

#解説解答
s = input()
n = len(s)
here = n
t = ''
while here > 0:
  try:
    if s[here-1:here] == 'm':
      t = 'dream' + t
      here -= 5
    elif s[here-1:here] == 'e':
      t = 'erase' + t
      here -= 5
    elif s[here-3:here] == 'mer':
      t = 'dreamer' + t
      here -= 7
    elif s[here-3:here] == 'ser':
      t = 'eraser' + t
      here -= 6
    else:
      break
  except:
    break
if s == t:
  print('YES')
else:
  print('NO')
### BUGGY CODE ###

def erat(n):
    l = [1 for _ in range(n)]
    i = 0
    while (i < n):
        if i == 0:
            l[i] = 0
        elif l[i] == 1:
            for j in range(i + 2, n + 1):
                if not j % (i + 1):
                    l[j - 1] = 0
            # l = list(map(lambda x: 1 if x % (i + 1) else 0, l))
        i += 1

    return l


n_max = 10**5

is_prime = erat(n_max)
is_2017 = [0 for _ in range(n_max)]
for i in range(2, n_max + 1):
    if is_prime[i - 1] and is_prime[(i + 1) // 2 - 1]:
        is_2017[i - 1] = 1

s = [0]
for i in range(n_max):
    s.append(s[i] + is_2017[i])


print('plz input.')
q = int(input())
ans = []
for _ in range(q):
    li, ri = map(int, input().split())
    ans.append(s[ri] - s[li - 1])

for a in ans:
    print(a)

### FIXED CODE ###

def get_prime_list(n):
    l = [0 for _ in range(n)]
    i = 1
    while (i < n):
        for j in range(2, int((i + 1)**0.5) + 1):
            if not (i + 1) % j:
                break
        else:
            l[i] = 1
        i += 1

    return l


n_max = 10**5
is_prime = get_prime_list(n_max)
is_2017 = [0 for _ in range(n_max)]
for i in range(2, n_max + 1):
    if is_prime[i - 1] and is_prime[(i + 1) // 2 - 1]:
        is_2017[i - 1] = 1

s = [0]
for i in range(n_max):
    s.append(s[i] + is_2017[i])

q = int(input())
for _ in range(q):
    li, ri = map(int, input().split())
    print(s[ri] - s[li - 1])
### BUGGY CODE ###

X, Y, Z, K = map(int, input().split())
A =list(map(int, input().split()))
B =list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort(reverse = True)
B.sort(reverse = True)
C.sort(reverse = True)
AB =[]
ABC = []
for i in range(X):
    for j in range(Y):
        ab = A[i] + B[j]
        AB.append(ab)
AB.sort(reverse = True)
for i in range(min(K, X*Y)):
    for j in range(Z):
        abc = AB[i] + C[j]
        ABC.append(abc)
ABC.sort(reverse = True)
for i in range(K):
    print(ABC[i])

### FIXED CODE ###

x, y, z, k = map(int, input().split())
a =list(map(int, input().split()))
b =list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort(reverse = True)
b.sort(reverse = True)
c.sort(reverse = True)
abc = []
for i in range(x):
    if (i+1) > k:
        break
    for j in range(y):
        if (i+1)*(j+1) > k:
            break
        for h in range(z):
            if (i+1)*(j+1)*(h+1) >k:
                break
            abc.append(a[i] +b[j] +c[h])
abc.sort(reverse = True)
for i in range(k):
    print(abc[i])
### BUGGY CODE ###

N=int(input())
L=[]
A=0

for i in range(N):
  d=sorted(str(input()))
  if d in L:
    A+=L.count(d)
  L.append(d)

print(A)

### FIXED CODE ###

n = int(input())
s = [''.join(sorted(input())) for _ in range(n)]
d = {}
ans = 0
for string in s:
    if string in d:
        ans += d[string]
        d[string]+=1
    else:
        d[string]=1
print(ans)
### BUGGY CODE ###

k,s = map(int,input().split())
count = 0

if 3*k < s:
    print(0)
else:
    for i in range(k+1):
        for j in range(k+1):
            for t in range(k+1):
                if (i+j+t) == s:
                    count += 1
    print(count)    


### FIXED CODE ###

k,s = map(int,input().split())
count = 0

for i in range(k+1):
    for j in range(k+1):
        z = s - i - j
        if z >= 0 and z <= k:
            count += 1

print(count)
### BUGGY CODE ###

N = int(input())
ratios = [[i for i in map(int,input().split())] for j in range(N)]

ans_a = 0
ans_t = 0
ratio = ratios.pop(0)
ans_a = ratio[0]
ans_t = ratio[1]

for ratio in ratios:
  i = 1
  while True:
    temp_a = ratio[0]*i
    temp_t = ratio[1]*i
    if temp_a >= ans_a and temp_t >= ans_t:
      ans_a = temp_a
      ans_t = temp_t
      break
    i += 1
    
print(ans_a + ans_t)

### FIXED CODE ###

N = int(input())
ratios = [[i for i in map(int,input().split())] for j in range(N)]

ans_a = 0
ans_t = 0
ratio = ratios.pop(0)
ans_a = ratio[0]
ans_t = ratio[1]

for ratio in ratios:
  i = max(ans_a // ratio[0], ans_t // ratio[1])
  while True:
    temp_a = ratio[0]*i
    temp_t = ratio[1]*i
    if temp_a >= ans_a and temp_t >= ans_t:
      ans_a = temp_a
      ans_t = temp_t
      break
    i += 1
    
print(ans_a + ans_t)
### BUGGY CODE ###

a,b,k=map(int,input().split())
for i in range(k):
  if a!=0:
    a-=1
  elif b!=0:
    b-=1
  else:
    break
print(a,b)

### FIXED CODE ###

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

def main():
	
	k = int(input())
	h = list(map(int,input().split()))
	ans = 1
	avoid = 0
	for i in h:
		ans = i * ans

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


if __name__ == '__main__':
	main()

### FIXED CODE ###

def main():
	k = int(input())
	h = tuple(map(int,input().split()))
	ans = 1
	avoid = 0
	if (0 in h):
		print(0)
	else:
		for i in range(k):
			ans = h[i] * ans
			if ans > 10 **18:
				print(-1)
				avoid = 1
				break
		if avoid == 0:
			print(ans)
	


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

#!/usr/bin/env python
n = int(input())
a = list(map(int, input().split()))
ans = float('inf')
for i in range(1, n):
    ans = min(ans, abs(sum(a[:i])-sum(a[i:])))
print(int(ans))

### FIXED CODE ###

#!/usr/bin/env python
n = int(input())
a = list(map(int, input().split()))
total = sum(a)
ans = float('inf')
tmp = 0
for i in range(n):
    tmp += a[i]
    if i==n-1:
        continue
    ans = min(ans, abs(tmp-(total-tmp)))
print(int(ans))
### BUGGY CODE ###

n=int(input())
x,y=1,1
for _ in range(n):
  t,a=map(int,input().split())
  if t>a:
    for i in range(x-x%t,x*1000+1,t):
      if i>=x and i//t*a>=y:break
    x,y=i,i//t*a
  else:
    for i in range(y-y%a,y*1000+1,a):
      if i>=y and i//a*t>=x:break
    x,y=i//a*t,i
print(x+y)

### FIXED CODE ###

n=int(input())
x,y=1,1
for _ in range(n):
  t,a=map(int,input().split())
  m=max((x+t-1)//t,(y+a-1)//a)
  x,y=m*t,m*a
print(x+y)
### BUGGY CODE ###

import heapq
def SME(start,end):
    if end > N : end = N
    count = 0
    for i,x in enumerate(Whole[start:end]):
        heapq.heappush(A,[x,i])
    for j in range(start,end):
        a = heapq.heappop(A)
        if None not in ANS[a[1]:a[1]+L] : continue
        for i in range(L):
            idx = a[1] + i
            try :
                if ANS[idx] : continue
                else :
                    ANS[idx] = a[0]
                    count += 1
            except IndexError : continue
        if count > N * parameter : break
    for i in range(L):
        if ANS[i] : continue
        else : ANS[i] = min(Whole[:i+1])
    for i in range(L,N):
        if ANS[i] : continue
        else : ANS[i] = min(Whole[i+1-L:i+1])
    return ANS
[N,L] = [int(x) for x in input().split()]
Whole = [int(x) for x in input().split()]
A = []
parameter = 0.99977
ANS = [None]*N
ANS = SME(0, N)
for i in ANS[L-1:-1]:print(i, end=" ")
print(ANS[-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 ###

from collections import Counter

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

for a in A:
    A = [x for x in A if (x == a or x % a != 0)]

counter = Counter(A)
print(len([0 for v in counter.values() if v == 1]))


### FIXED CODE ###

from collections import Counter
import numpy as np

A_MAX = 10 ** 6 + 1

N = int(input())
A = Counter(list(map(int, input().split(' '))))

dp = np.zeros(shape=A_MAX, dtype=np.int64)

if A[1] == 1:
    print(1)
elif A[1] > 1:
    print(0)
else:
    for a in A.keys():
        multiples = np.arange(a, A_MAX, a)
        np.add.at(dp, multiples, 1)

    ans = 0
    for a, count in A.items():
        if count > 1:
            continue
        if dp[a] == 1:
            ans += 1

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

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

for k in K:
    ans = 0
    d,m,dm=0,0,0
    j=0
    for i in range(N):
        if i-j == k:
            if S[j]=='D':
                d -= 1
                dm -= m
            elif S[j]=='M':
                m -= 1
            j += 1

        if S[i] == 'D':
            d += 1
        elif S[i] == 'M':
            m += 1
            dm += d
        elif S[i] == 'C':
            ans += dm
    print(ans)


### FIXED CODE ###

N=int(input())
S=tuple(map(ord,input()))
Q=int(input())
K=map(int,input().split())
D,M,C=map(ord,'DMC')

for k in K:
    ans=0
    d=m=dm=0
    for i in range(min(k-1,N)):
        c=S[i]
        if c==D:
            d+=1
        elif c==M:
            m+=1
            dm+=d
        elif c==C:
            ans+=dm
    for i in range(k-1,N):
        c=S[i]
        if c==D:
            d+=1
        elif c==M:
            m+=1
            dm+=d
        elif c==C:
            ans+=dm
        c=S[i-(k-1)]
        if c==D:
            d-=1
            dm-=m
        elif c==M:
            m-=1
    print(ans)
### BUGGY CODE ###

"""
--- アルゴリズム概要 ---
前計算で頂点Kから各ノードへの最短路を記録しておき、
各クエリに対しては、dp[a]+dp[b]を返せばよい。

頂点Kから各ノードへの最短ルートはdfsとかで記録していけばよい。
"""
def main():
    import sys
    sys.setrecursionlimit(20000000)
    input = sys.stdin.readline
    N = int(input())
    AB = [{}for _ in range(N+1)]
    for i in range(N-1):
        a,b,c = map(int,input().split())
        AB[a][b] = c
        AB[b][a] = c

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

    path = {K:""}
    dp = [0]*(N+1)
    def dfs(n,cost):
        path[n]=""
        dp[n]=cost
        for i,c in AB[n].items():
            if i not in path:
                nextcost = cost+c
                dfs(i,nextcost)
    dfs(K,0)
    for i in range(Q):
        x,y=map(int,input().split())
        print(dp[x]+dp[y])
main()

### FIXED CODE ###

"""
--- アルゴリズム概要 ---
前計算で頂点Kから各ノードへの最短路を記録しておき、
各クエリに対しては、dp[a]+dp[b]を返せばよい。

頂点Kから各ノードへの最短ルートはdfsとかで記録していけばよい。
"""
def main():
    from collections import deque
    import sys
    sys.setrecursionlimit(20000000)
    input = sys.stdin.readline
    N = int(input())
    AB = [[]for _ in range(N+1)]
    for i in range(N-1):
        a,b,c = map(int,input().split())
        AB[a].append((b,c))
        AB[b].append((a,c))

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

    path = {K:""}
    dp = [0]*(N+1)
    que = deque()
    for n,c in AB[K]:
        que.append((n,c))
    while que:
        now,cost = que.pop()
        path[now]=""
        dp[now]=cost
        for n,c in AB[now]:
            if n not in path:
                que.append((n,cost+c))
    for i in range(Q):
        x,y=map(int,input().split())
        print(dp[x]+dp[y])
main()
### BUGGY CODE ###

import fractions
from functools import reduce

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

n = int(input())
li = list(map(int,input().split()))

max_gcd = 0
for i in range(len(li)):
    tmp = li[i]
    del li[i]
    tmp_gcd = gcd(*li)
    if max_gcd < tmp_gcd:
        max_gcd = tmp_gcd
    li.insert(0,tmp)

print(max_gcd)

### FIXED CODE ###

from fractions import gcd

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

# 入力が2つなら最大値が解となる
if n == 2:
    print(max(A))
    exit()

# A1 A2 A3の最大公約数はA1とA2の最大公約数とA3の最大公約数と同値になるので、
# 左右から順番に最大公約数を求めていく。
# 初期値を代入する（右からは0番目にAの最初の要素を、左からは末尾にAの末尾の要素）
gcdL = [0]*n
gcdR = [0]*n
gcdL[0] = A[0]
gcdR[-1] = A[-1]

for i in range(1, n):
    gcdL[i] = gcd(gcdL[i-1], A[i])
    gcdR[-i-1] = gcd(gcdR[-i], A[-i-1])

# A0～AiとAi+1～Anの最大公約数を求めていく
# 最大値が解となる
ans = gcdR[1]
for i in range(1, n-1):
    tmp = gcd(gcdL[i-1], gcdR[i+1])
    ans = max(ans, tmp)
ans = max(ans, gcdL[-2])

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

n = int(input())
p = list(map(float, input().split()))

dp = [[0]*(n+1) for _ in range(n+1)]
dp[0][0] = 1
# dp[i][j]:i番目以前の商品を見たときに表の枚数がj枚となる確率の和

for i in range(1,n+1):
    for j in range(i+1):
            dp[i][j] = dp[i-1][j]*(1-p[i-1])
            if j>0:
                dp[i][j] += dp[i-1][j-1]*p[i-1]

ans = sum(dp[n][(n+1)//2:])

print(ans)

### FIXED CODE ###

n = int(input())
p = list(map(float, input().split()))

dp = [[0]*(n+1) for _ in range(n+1)]
dp[0][0] = 1
# dp[i][j]:i番目以前の商品を見たときに表の枚数がj枚となる確率の和

for i in range(1,n+1):
    for j in range(i+1):
            dp[i][j] = dp[i-1][j]*(1-p[i-1])
            if j>0:
                dp[i][j] += dp[i-1][j-1]*p[i-1]

ans = sum(dp[n][(n+1)//2:])

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

n = int(input())
power = 1

for i in range(1,n+1):
  power *= i
  
print(power % (pow(10,9) + 7))

### FIXED CODE ###

INF = 1000000007
n = int(input())

ans = 1


for i in range(1,n+1):
  ans = ans * i % INF
  
print(ans)
### BUGGY CODE ###

import math
from functools import reduce


def gcd(*numbers):
    return reduce(math.gcd, numbers)


def gcd_list(numbers):
    return reduce(math.gcd, numbers)


K = int(input()) + 1
sum = 0
for i in range(1, K):
    for j in range(1, K):
        for k in range(1, K):
            sum += gcd(i, j, k)

print(sum)


### FIXED CODE ###

import math
from functools import reduce


def gcd(*numbers):
    return reduce(math.gcd, numbers)


def gcd_list(numbers):
    return reduce(math.gcd, numbers)


K = int(input()) + 1
sum = 0
for i in range(1, K):
    for j in range(1, K):
        for k in range(1, K):
            sum += gcd(i, j, k)

print(sum)
### BUGGY CODE ###

from sys import stdin
data = stdin.readline().rstrip()

a = int(data)

def factorization(n):
    def factor_sub(n, m):
        c = 0
        while n % m == 0:
            c += 1
            n /= m
        return c, n
    #
    buff = []
    c, m = factor_sub(n, 2)
    if c > 0: buff.append((2, c))
    c, m = factor_sub(m, 3)
    if c > 0: buff.append((3, c))
    x = 5
    while m >= x * x:
        c, m = factor_sub(m, x)
        if c > 0: buff.append((x, c))
        if x % 6 == 5:
            x += 2
        else:
            x += 4
    if m > 1: buff.append((m, 1))
    return buff
def divisor_num(n):
    a = 1
    for _, x in factorization(n):
        a *= x + 1
    return a

ans = 0
for i in range(1,a+1):
    ans += i*divisor_num(i)
print(ans)

### FIXED CODE ###

from sys import stdin
data = stdin.readline().rstrip()

a = int(data)

ans = 0
for i in range(1,a+1):
    tmp = a//i
    ans += int(i * tmp * (tmp +1) / 2)
print(ans)
### BUGGY CODE ###

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

AL = [0]
for i in range(N):
    AL.append(AL[-1] + A[i])

BL = [0]
for i in range(M):
    BL.append(BL[-1] + B[i])

ans = 0
for i in range(N+1):
    for j in range(M+1):
        if AL[i] + BL[j] <= K:
            ans = max(ans, i+j)
        else:
            break

print(ans)

### FIXED CODE ###

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

AL = [0]
for i in range(N):
    AL.append(AL[-1] + A[i])
BL = [0]
for i in range(M):
    BL.append(BL[-1] + B[i])

ans = 0
from bisect import bisect_right
for i in range(N+1):
    zan = K - AL[i]
    if zan < 0:
        break
    ind = bisect_right(BL, zan) - 1
    ans = max(ans, i + ind)

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

N = int(input())
D = [int(i) for i in input().split()]

cnt = 0


for i in range(1,max(D)+1):
	arc = []
	abc = []
	for j in range(len(D)):
		if D[j] > i:
			arc.append(D[j])
		else:
			abc.append(D[j])
		#print(abc, arc)
	if len(arc) == len(abc):
		cnt += 1

print(cnt)

### FIXED CODE ###

N = int(input())
D = [int(i) for i in input().split()]
D.sort()
print(D[N//2] - D[N//2-1])
### BUGGY CODE ###

N = int(input())
A = sorted(list(map(int,input().split())))
def gcd(L):
    nextminb = L[0]
    while True:
        #print(L)
        minb = nextminb
        for i in range(len(L)):
            r = L[i] % minb
            if r != 0:
                L[i] = r
                if r < nextminb :
                    nextminb = r
        if minb == nextminb:
            return minb


lgcd = [0] * N
rgcd = [0] * N

for i in range(N):
    lgcd[i] = gcd(A[0:i+1])
    rgcd[i] = gcd(A[i:])
maxg = max(lgcd[N-2],rgcd[1])
for i in range(1,N-1):
    g = gcd([lgcd[i-1],rgcd[i+1]])
    if maxg < g:
        maxg = g

print(maxg)


### FIXED CODE ###

N = int(input())
A = sorted(list(map(int,input().split())))
def gcdaaaaaaaaa(L):
    nextminb = L[0]
    nextn = len(L)
    while True:
        n = nextn
        minb = nextminb
        for l in L[:n]:
            nextn = 0
            r= l % minb
            
            if r != 0:
                L[nextn] = r
                nextn += 1
                if r < nextminb :
                    nextminb = r
        if minb == nextminb:
            return minb
        
def gcd(a,b):
    r = a % b
    if r == 0:
        return b
    else:
        return gcd(b,r)
def gcdL(L):
    g = L[0]
    for l in L:
        g = gcd(g,l)
    return g



lgcd = [0] * N
rgcd = [0] * N

lg = A[0]
rg = A[-1]
for i in range(N):
    
    lg = gcd(lg,A[i])
    lgcd[i] = lg
    rg = gcd(rg,A[N-i-1])
    rgcd[N-i-1] = rg
    
maxg = max(lgcd[N-2],rgcd[1])
for i in range(1,N-1):
    g = gcd(lgcd[i-1],rgcd[i+1])
    if maxg < g:
        maxg = g

print(maxg)
### BUGGY CODE ###

n = int(input())
ki = [[] for _ in range(n)]
dlist = [[0]*n for _ in range(n)]
dist = [0]*n
for i in range(n-1):
    a,b,c  = map(int,input().split())
    a -= 1
    b -= 1
    ki[a].append(b)
    ki[b].append(a)
    dlist[a][b] = dlist[b][a] = c
q,k = map(int,input().split())
k -= 1
def dfs(now,last = -1):
    for next in ki[now]:
        if next == last:continue
        dist[next] = dist[now] + dlist[now][next]
        dfs(next,now)
dfs(k)
for i in range(q):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    print(dist[x]+dist[y])

### FIXED CODE ###

# solution

data=int(input())

abc=[list(map(int,input().split())) for _ in [0]*(data-1)]

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

array1=[list(map(int,input().split())) for _ in [0]*q]

k-=1

tree=[[] for _ in [0]*data]

dist=[-1]*data

dist[k]=0

[tree[a-1].append([b-1,c]) for a,b,c in abc]

[tree[b-1].append([a-1,c]) for a,b,c in abc]

q=[k]

while(q):
	qq=[]
	for i in q:
		for j,k in tree[i]:
			if dist[j]<0:
				dist[j]=dist[i]+k
				qq.append(j)
	q=qq

for x,y in array1:
	print(dist[x-1]+dist[y-1])
### BUGGY CODE ###

N = int(input())
A = input()
a = A.split()
sum = 1
for i in range(N):
    sum *= int(a[i])
if sum > 10**18:
    print(-1)
else:
    print(sum)

### FIXED CODE ###

N = int(input())
A = input()
a = A.split()
s = 1
flag = 0
if "0" in a:
    print(0)
else:
    for i in range(N):
        s *= int(a[i])
        if s > 10**18:
            print(-1)
            flag = 1
            break
    if flag == 0:
        print(s)
### BUGGY CODE ###

#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    n = II()
    a = LI()
    ans = 1
    for ai in a:
        ans *= ai
    if ans > 10 ** 18:
        print(-1)
    else:
        print(ans)
    return


#main
if __name__ == '__main__':
    solve()


### FIXED CODE ###

#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    n = II()
    a = LI()
    a.sort()
    ans = 1
    for ai in a:
        ans *= ai
        if ans > 10 ** 18:
            print(-1)
            return
    print(ans)
    return


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

import copy
n = int(input())
a = [int(input()) for _ in range(n)]
b = copy.copy(a)
b.sort(reverse=True)
s = b[1]
m = max(a)

for i in range(n):
    if a[i] != max(a):
        print(max(a))
    else:
        print(s)

### FIXED CODE ###

import copy
n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))
b = copy.copy(a)
a.sort(reverse=True)
for i in range(n):
    if b[i] == a[0]:
        print(a[1])
    else:
        print(a[0])