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

import numpy as np
import copy

N = int(raw_input().replace("\n", ""))

a_array = np.asarray([int(raw_input().replace("\n", "")) for i in xrange(N)])
len_array = a_array.shape[0]

sum_diffs = []
for elm_i, start_elm in enumerate(a_array):
    mask = np.ones(len_array, dtype=bool)
    target_elm = start_elm
    #mask[elm_i] = False

    sum_diff = 0
    #while True:
    for count in xrange(len_array - 1):
        #a_list.remove(target_elm)
        mask[elm_i] = False
        a_list = a_array[mask]
        #print(a_array, mask, a_list, count)
        #a_array = np.abs(np.asarray(a_list) - target_elm)
        tmp = np.abs(a_list - target_elm)
        #target_elm_index = np.argmax(a_array)
        target_elm_index = np.argmax(tmp)
        target_elm = a_list[target_elm_index]
        sum_diff += tmp[target_elm_index]
        #print("sum_diff:", sum_diff)
        
        count_ = -1
        for mask_i, elm in enumerate(mask):
            if elm:
                count_ += 1
                if count_ == target_elm_index:
                    elm_i = mask_i
                    break
        #print target_elm_index, elm_i
    
    sum_diffs.append(sum_diff)

#print sum_diffs
print max(sum_diffs)

### FIXED CODE ###

import numpy as np
import copy

N = int(raw_input().replace("\n", ""))

a_array = np.asarray(sorted([int(raw_input().replace("\n", "")) for i in xrange(N)]))

len_array = len(a_array)

coffs = np.ones(len(a_array), dtype=bool) * 2

if len_array % 2 == 0:
    coffs = [-2] * ((len_array - 1) / 2) + [-1] + [1] + [2] * ((len_array -1) / 2)
    out = np.dot(a_array, coffs)
else:
    coffs1 = [-2] * ((len_array-3) / 2) + [-1] * 2 + [2] * ((len_array-1) / 2)
    coffs2 = [-2] * ((len_array-1) / 2) + [1] * 2 + [2] * ((len_array-3) / 2)
    out1 = np.dot(a_array, coffs1)
    out2 = np.dot(a_array, coffs2)
    out = max(out1, out2)

print out
### BUGGY CODE ###

import numpy as np
n = int(input())
fs = []
for _ in range(n):
    r = list(input())
    r = [ord(s) - ord("a") for s in r]    
    fs.append(r)
fs = np.array(fs)
sym = np.zeros((n,n))
cnt = 0
# di,dj とdi+1,dj+1が同値
# dj側は0で固定して良い
for di in range(n):
    for i in range(n):
        for j in range(n):
            sym[(i+di)%n][j] = fs[i][j]
    if (sym == sym.T).all():
        cnt += n
print(cnt)


### FIXED CODE ###

n = int(input())
fs = []
for _ in range(n):
    r = list(input())
    r = [ord(s) - ord("a") for s in r]    
    fs.append(r)
sym = [[0]*n for i in range(n)]
cnt = 0
# di,dj とdi+1,dj+1が同値
# dj側は0で固定して良い
for di in range(n):
    for i in range(n):
        for j in range(n):
            sym[(i+di)%n][j] = fs[i][j]
    flg = True
    for i in range(n):
        for j in range(i+1,n):
            if sym[i][j] != sym[j][i]:
                flg = False
                break
    if flg:
        cnt += n
print(cnt)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
R, G, B, N = map(int, input().split())
cnt = 0
for i in range(int(N/R)+1):
    r = i*R
    for j in range(int(N/G)+1):
        g = j*G
        b = N - g - r
        if b >= 0 and b % B == 0:
            cnt += 1
print(cnt)

### FIXED CODE ###

R, G, B, N = map(int, input().split())
cnt = 0
for i in range(int(N/R)+1):
    r = i*R
    for j in range(int(N/G)+1):
        g = j*G
        b = N - g - r
        if b >= 0 and b % B == 0:
            cnt += 1
print(cnt)
### BUGGY CODE ###

def prime_factor(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])
    if arr == []:
        arr.append([n, 1])
    return arr


try:
    from math import gcd
except ImportError:
    from fractions import gcd

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

n = 1
c = prime_factor(A[0])[0][1]
for a in A:
    if c != prime_factor(a)[0][1]:
        print(0)
        exit()
    n = (n*a)//gcd(n, a)

n //= 2

if n > m:
    ans = 0
else:
    ans = m//n
    ans = (ans+1)//2

print(ans)


### FIXED CODE ###

def prime_factor(n):
    arr = []
    temp = n
    for i in range(2, 3):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])
    if arr == []:
        arr.append([n, 1])
    return arr


try:
    from math import gcd
except ImportError:
    from fractions import gcd

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

n = 1
c = prime_factor(A[0])[0][1]
for a in A:
    if c != prime_factor(a)[0][1]:
        print(0)
        exit()
    n = (n*a)//gcd(n, a)

n //= 2

if n > m:
    ans = 0
else:
    ans = m//n
    ans = (ans+1)//2

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

# https://beta.atcoder.jp/contests/agc014/submissions/1268295
import sys


def solve():
    H, W, K = map(int, sys.stdin.readline().split())
    a = [[False for _ in range(W)] for _ in range(H)]
    visited = [[False for _ in range(W)] for _ in range(H)]

    sy, sx = -1, -1
    for r in range(H):
        s = sys.stdin.readline().rstrip()
        for c, x in enumerate(s):
            if x == '.':
                a[r][c] = True
            elif x == 'S':
                a[r][c] = True
                sy, sx = r, c

    # print(sy, sx)
    q = [(sy, sx, 0)]
    t = max(H, W)
    n = 1
    i = 0
    while i < n:
        r, c, k = q[i]
        visited[r][c] = True

        t = min(t, r, H - 1 - r, c, W - 1 - c)
        # print(t)
        if t == 0:
            print(1)
            return

        for dr, dc in (-1, 0), (1, 0), (0, -1), (0, 1):
            nr, nc = r + dr, c + dc
            if 0 <= nr < H and 0 <= nc < W and a[nr][nc] and not visited[nr][nc] and k + 1 <= K:
                q.append((nr, nc, k + 1))
                n += 1
        i += 1

    ans = 1 + (t + K - 1) // K

    print(ans)


if __name__ == '__main__':
    solve()


### FIXED CODE ###

# https://beta.atcoder.jp/contests/agc014/submissions/1268295
from collections import deque

dr = (0, 1, 0, -1)
dc = (1, 0, -1, 0)


def solve():
    H, W, K = map(int, input().split())
    a = [[False for _ in range(W)] for _ in range(H)]

    sy, sx = -1, -1
    for r in range(H):
        s = input()
        for c, x in enumerate(s):
            if x == '.':
                a[r][c] = True
            elif x == 'S':
                a[r][c] = True
                sy, sx = r, c

    visited = [[False for _ in range(W)] for _ in range(H)]
    visited[sy][sx] = True

    t = max(H, W)
    q = deque([(sy, sx, 0)])
    while q:
        r, c, k = q.popleft()

        t = min(t, r, H - 1 - r, c, W - 1 - c)
        # print(t)
        if t == 0:
            print(1)
            return

        for d_i in range(4):
            nr, nc = r + dr[d_i], c + dc[d_i]
            if 0 <= nr < H and 0 <= nc < W and a[nr][nc] and not visited[nr][nc] and k + 1 <= K:
                visited[nr][nc] = True
                q.append((nr, nc, k + 1))

    ans = 1 + (t + K - 1) // K

    print(ans)


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

S = input()
N = len(S)
i = 1
cnt = 0

while(i+3<=N):
    j = i+3
    num = int(S[i-1:j])
    while(j<N):
        r = num % 2019
        if r == 0:
            cnt += 1
        num = r * 10 + int(S[j])
        j += 1
    r = num % 2019
    if r == 0:
        cnt += 1
    i += 1

print(cnt)

### FIXED CODE ###

s = input()
n = len(s)
p = 2019
 
 
 
digit_rm = [0 for _ in range(n)]
for i in range(n):
	digit_rm[i] = (int(s[n-1-i]) * pow(10, i, p) ) % p
 
remain = [0 for _ in range(n)]
for i in range(n):
	if i == 0:
		remain[i] = digit_rm[i]
	else:
		remain[i] = (remain[i-1] + digit_rm[i]) % p
 
pcnt = [0 for _ in range(p)]
 
for i in remain:
	pcnt[i] += 1
 
if 10 % p == 0:
	ans = 0
	for i in range(n):
		if int(s[n-1-i]) % p == 0:
			ans += n - i
	print(ans)
else:
	ans = pcnt[0]
	for num in pcnt:
		if num != 0:
			ans += num * (num - 1) // 2
 
	print(ans)
### BUGGY CODE ###

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))  # 整数のリスト

    next_A = [0 for _ in range(N)]

    for _ in range(K):
        if sum(A) == N**2: break
        for i in range(N):
            if A[i] > N: continue
            for j in range(i-A[i], i+A[i]+1):
                if j >= 0 and j < N:
                    next_A[j] += 1
        A = next_A
        next_A = [0 for _ in range(N)]

    for i in A:
        print(i, end=" ")

if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))  # 整数のリスト
    B = [0] * N

    for j in range(min(K, 41)):
        for i in range(N):
            l = max(0, i-A[i])
            r = min(N-1, i+A[i])
            B[l] += 1
            if r+1 < N: B[r+1] -= 1
        for i in range(1,N):
            B[i] += B[i-1]
        A = B
        B = [0] * N

    for i in A:
        print(i, end=" ")

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

string = list(input())
n = int(input())
while n:
    n-=1
    inp = input().split()
    if inp[0]=='1':
        string =string[::-1]
    else:
        if inp[1]=='1':
            string.insert(0,inp[2])
        else:
            string.append(inp[2])
s=''
for i in range(len(string)):
    s+=string[i]
print(s)

### FIXED CODE ###

s=list(input())
q=int(input())
c=0
left=[]
right=[]
for i in range(q):
    s1=input()
    if s1[0]=='1':
        c+=1
    else:
        if s1[2] == '1':
            if c % 2 == 0:
                left.append(s1[4])
            else:
                right.append(s1[4])
        else:
            if c % 2 == 0:
                right.append(s1[4])
            else:
                left.append(s1[4])
left=left[::-1]
left.extend(s)
left.extend(right)
if c%2==0:
    print(''.join(left))
else:
    left=left[::-1]
    print(''.join(left))
### BUGGY CODE ###

N=int(input())
S=str(input())
t=0
for i in range(N):
    for j in range(i+1,N):
        if S[i]==S[j]:
            continue
        else:
            for k in range(j+1,N):
                if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i] and (i-j)!=(j-k):
                    t=t+1
                else:
                    continue
print (t) 

### FIXED CODE ###

N=int(input())
S=str(input())
t=0
r=0
b=0
g=0
for i in range(N):
    if S[i]=='R':
        r+=1
    elif S[i]=='B':
        b+=1
    else:
        g+=1
for i in range(N):
    for j in range(i+1,N):
        if S[i]==S[j]:
            continue
        else:
            try:
                if S[2*j-i]!=S[j] and S[2*j-i]!=S[i]:
                    t+=1
                else:
                    continue
            except IndexError:
                break
print (r*b*g-t)
### BUGGY CODE ###

n = int(input())
s = input()

ans = 0

while ans <= len(s)//2:
    prev_s = ''
    for i in range(1, len(s)//2+1):
        if s[:i] in s[i:]:
            prev_s = s[:i]
        else:
            ans = max(ans, len(prev_s))
            break
    else:
        ans = max(ans, len(prev_s))
    s = s[1:]
    if len(s) == 1:
        break

print(ans)


### FIXED CODE ###

n = int(input())
s = input()

ans = 0

while ans <= len(s)//2:
    prev_s = ''
    for i in range(ans+1, len(s)//2+1):
        if s[:i] in s[i:]:
            prev_s = s[:i]
        else:
            ans = max(ans, len(prev_s))
            break
    else:
        ans = max(ans, len(prev_s))
    s = s[1:]
    if len(s) == 1:
        break

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

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

def ans() :
    n, m  = map(int, input().split())
    a = list(map(int, input().split()))

    for i in range(m):
        a[a.index(max(a))] = a[a.index((max(a)))] >> 1

    print(sum(a))

if __name__ == '__main__':
    ans()

### FIXED CODE ###

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

import heapq

def ans() :
    n, m  = map(int, input().split())
    aa = map(int, input().split())
    a = []
    for i in aa:
        heapq.heappush(a, int(i) * (-1))

    for i in range(m):
        head = heapq.heappop(a)
        head = (-1) * (-head // 2)
        heapq.heappush(a, head)

    print(-sum(a))

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

N,K=map(int,input().split())
S=N
f=[]
while S>K:
    S=abs(S-K)

f.append(abs(S))
f.append(abs(S-K))
f.append(abs(S-2*K))

    
    
    
print(min(f))


### FIXED CODE ###

N,K=map(int,input().split())
S=N
if N%K==0:
    print(0)
else:
    print(min(N%K,abs(N%K-K)))
### BUGGY CODE ###

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


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


count=0
if N>=M:
    for i in range(N-M):
        x1=np.argmin(A)
        x1=A.pop(x1)
        count+=x1
    print(count)



else:
    print(0)


### FIXED CODE ###

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


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

count=0
if N>=M:
    for i in range(N-M):
        count+=A[i]
    print(count)



else:
    print(0)
### BUGGY CODE ###

import itertools

n=int(input())
list1=[]
for j in range(n):
  s=input()
  if s[0]=='M' or s[0]=='A' or s[0]=='R' or s[0]=='C' or s[0]=='H':
    list1.append(s[0])

list1.sort()

list2=list(itertools.combinations(list1, 3))

cnt=0
for j in range(len(list2)):
  if len(list2[j])==len(set(list2[j])):
    cnt+=1

print(cnt)


### FIXED CODE ###

n=int(input())

m=0;a=0;r=0;c=0;h=0

for i in range(n):
  s=input()
  if s[0]=='M':
    m+=1
  elif s[0]=='A':
    a+=1
  elif s[0]=='R':
    r+=1      
  elif s[0]=='C':
    c+=1      
  elif s[0]=='H':
    h+=1

#print(m,a,r,c,h)
ans=0
ans+=m*a*r
ans+=m*a*c
ans+=m*a*h
ans+=m*r*c
ans+=m*r*h
ans+=m*c*h
ans+=a*r*c
ans+=a*r*h
ans+=a*c*h
ans+=r*c*h

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

X = int(input())
c = 0
for i in range(int(X/100)+1):
    for j in range(int((X-100*i)/101)+1):
        for k in range(int((X-100*i-101*j)/102) +1):
            for l in range(int((X-100*i-102*j-103*k)/103) +1):
                for m in range(int((X-100*i-101*j-102*k-103*l)/104)+1):
                    if (X-100*i-101*j-102*k-103*l-104*m) % 105 == 0:
                        c = 1
                            
print(c)


### FIXED CODE ###

X= int(input())
val = X // 100
diff = X % 100
if diff <= 5*val:
    print(1)
else:
    print(0)
### BUGGY CODE ###

import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10**9)
INF = 10**9
mod = 10**9+7

N = i()
S = [l() for _ in range(N)]
ans = 0
for _ in range(N):
    pq = []
    for i in S:
        for j in S:
            if i == j:
                continue
            pq.append((i[0]-j[0],i[1]-j[1]))
    for p,q in pq:
        cnt = 0
        for i in S:
            for j in S:
                if i == j:
                    continue
                if (i[0]-j[0],i[1]-j[1]) == (p,q):
                    cnt += 1
        ans = max(ans,cnt)
print(N-ans)

### FIXED CODE ###

import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10**9)
INF = 10**9
mod = 10**9+7

N = i()
S = [l() for _ in range(N)]
ans = 0
pq = []
for i in S:
    for j in S:
        if i == j:
            continue
        pq.append((i[0]-j[0],i[1]-j[1]))
for p,q in set(pq):
    cnt = 0
    for i in S:
        for j in S:
            if i == j:
                continue
            if (i[0]-j[0],i[1]-j[1]) == (p,q):
                cnt += 1
    ans = max(ans,cnt)
print(N-ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

N = int(input())
L = [input().strip() for _ in range(N)]

m = [{} for _ in range(N)]
for i in range(N):
    for v in L[i]:
        if m[i].get(v) == None:
            m[i][v] = 0
        m[i][v] += 1
        
ans = 0
# very slow
for i in range(N):
    for j in range(i + 1, N):
        if m[i] == m[j]:
            ans += 1
            
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline

N = int(input())
L = [input().strip() for _ in range(N)]

m = [0 for _ in range(N)]
for i in range(N):
    p = list(L[i])
    p.sort()
    
    
    m[i] = "".join(p)

mm = {}
for i in range(N):
    if mm.get(m[i]) == None:
        mm[m[i]] = 0
    mm[m[i]] += 1


ans = 0
for v in mm.values():
    if v != 1:
        ans += v * (v - 1) // 2

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

def iput(): return int(input())
def mput(): return map(int, input().split())
def lput(): return list(map(int, input().split()))
 
def solve():
    n = iput()
    a = lput()
    ans = 1
    for i in range(n):
        ans *= a[i]
    if ans > 10**18:
        print(-1)
    else:
        print(ans)
    return 0
 
if __name__ == "__main__":
    solve()

### FIXED CODE ###

def iput(): return int(input())
def mput(): return map(int, input().split())
def lput(): return list(map(int, input().split()))
 
def solve():
    n = iput()
    a = lput()
    ans = 1
    if 0 in a:
        print(0)
        exit()
    for i in range(n):
        ans *= a[i]
        if ans > 10**18:
          print(-1)
          exit()
    print(ans)
    return 0
 
if __name__ == "__main__":
    solve()
### BUGGY CODE ###

tmp = raw_input()
s = list(set(map(int, raw_input().split())))
tmp = raw_input()
t = sorted(map(int, raw_input().split()))

max_n = s[-1]
min_n = s[0]
ans = 0

for i in t:
	if i > max_n or i < min_n: continue
	for j in range(len(s)):
		if i == s[j]:
			ans += 1
			break
		elif i <= s[j]:
			break
print ans

### FIXED CODE ###

input()
l = raw_input().split()
input()
print len(set(l) & set(raw_input().split()))
### BUGGY CODE ###

from math import factorial
n,k = map(int,input().split())
a = list(map(int,input().split()))
a.sort(reverse = True)
MOD = 10**9+7
ans = 0
for i in range(n):
  if n-i < k:
    continue
  C = ( factorial(n-i-1)//factorial(k-1) ) // factorial(n-i-k)
  C %= MOD
  ans += ((a[i]-a[n-i-1]) * C) % MOD
  ans %= MOD

print(ans)
  

### FIXED CODE ###

MAX = 100000 #階乗のmodを求めたい中で最大のもの
MOD = 10**9+7

fac = [0]*MAX   #階乗のmod
inv = [0]*MAX    #その数の逆元
finv = [0]*MAX   #階乗の逆元

def COMinit():
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2,MAX):
        fac[i] = (fac[i-1] * i) % MOD
        inv[i] = MOD-(inv[MOD%i] * (MOD//i))%MOD
        finv[i] = (finv[i-1]*inv[i]) %MOD
        
    
def COM(n,k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return (fac[n] * (finv[k]*finv[n-k]))%MOD

#pが素数でないと使えない
COMinit()
n,k = map(int,input().split())
a = list(map(int,input().split()))
a.sort(reverse = True)
MOD = 10**9+7
ans = 0
for i in range(n):
  if n-i < k:
    continue
  C = COM(n-i-1,k-1)
  ans += ((a[i]-a[n-i-1]) * C) % MOD
  ans %= MOD

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

def main():
    s = input()
    s_len = len(s)
    mod = 2019
    d = [0] * mod
    d[0] = 1
    rev_num = 0
    # 2以上なら共通するmodがあったということになる
    for i, s in enumerate(reversed(s)):
        rev_num += int(s) * (10**i%mod)
        rev_num %= mod
        d[rev_num] += 1
    # 2以上同じmodがあったらそこから2つ選ぶ選び方
    # それを全てのmodで
    print(sum(i*(i-1)//2 for i in d))
 
if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    s = input()
    s_len = len(s)
    mod = 2019
    d = [0] * mod
    d[0] = 1
    rev_num = 0
    t = 1
    # 2以上なら共通するmodがあったということになる
    for i in reversed(s):
        rev_num += int(i) * t
        rev_num %= mod
        d[rev_num] += 1
        t *= 10
        t %= mod
    # 2以上同じmodがあったらそこから2つ選ぶ選び方
    # それを全てのmodで
    print(sum(i*(i-1)//2 for i in d))
 
if __name__ == '__main__':
    main()
### BUGGY CODE ###

from collections import Counter
from queue import deque


y = 2019
S = deque(input())
N = len(S)
T = [0] * (N + 1)

for i in range(N-1, -1, -1):
    T[i] = T[i+1] + int(S[i]) * 10 ** (N - 1 - i)
    
T = [t % y for t in T]

cnt = 0
for c in Counter(T).values():
    cnt += c * (c - 1) // 2
    
print(cnt)

### FIXED CODE ###

from queue import deque
 
    
S = deque(input())
y = 2019
U = [0] * y
t = 0
U[0] = 1
k = 1

for s in reversed(S):
    t = t + int(s) * k
    t %= y
    U[t] += 1
    k *= 10
    k %= y

cnt = 0
for u in U:
    cnt = cnt + u * (u - 1) // 2

print(cnt)
### BUGGY CODE ###

n = int(input())
cnt = 0
moji = []
for i in range(n):
    s = sorted(list(input()))
    cnt += moji.count(s)
    moji.append(s)
print(cnt)

### FIXED CODE ###

n = int(input())
cnt = 0
moji = {}
for i in range(n):
    s = ''.join(sorted(list(input())))
    if not s in moji.keys():
        moji[s] = 0 
    cnt += moji[s]
    moji[s] += 1
print(cnt)
### BUGGY CODE ###

from math import factorial as fact
import math
import sys
import itertools
import numpy as np
from collections import Counter
import datetime
from collections import deque


#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))

def keta(N):
	return len(str(N))


def input_daytime(input_time):
	time,distance=input_time.split()
	t=time.split(":")
	se=str(t[-1]).split(".")
	dt1 = datetime.timedelta(hours=int(t[0]),minutes=int(t[1]),seconds=int(se[0]),milliseconds=int(se[1]))
	return dt1

def combinations(n,r):
	return list(itertools.combinations(range(n),r))



def all_sets(num_list):
	subsets=[]
	for i in range(2,len(num_list) + 1):
		for c in combinations(num_list, i):
			subsets.append(c) 
	return subsets

#公約数の列挙
def ch(x1):
	cf=[]
	for i in range(2,math.sqrt(x1)+1):
		if x1 % i==0:
			cf.append(i)
	return cf

def CountOneRoots(x,y):
	#x:縦，y:横
	return fact(x+y)/fact(x)/fact(y)

# 素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
	
def count_str(m):
	tmp={}
	for i in range(10):
		if i in tmp:
			tmp[i]=1
		else:
			tmp[i]+=1
	return tmp

def is_prime(n):
	if n==1: return True

	for i in range(2,int(math.sqrt(n))+1):
		if n%i==0:
			return False
	return True


n=input1()
A=input_array()
if n>10**5:
	sys.exit()
ans=1
flag=True
for a in A:
	if a > 10**18:
		sys.exit()
	ans=ans*a

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




### FIXED CODE ###

import sys

#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))
  
n=input1()
A=input_array()
if 0 in A:
	print(0)
	sys.exit()
ans=1

for a in A:
	ans=ans*a
	if ans > 10**18:
		break

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

import sys
sys.setrecursionlimit(10**8)

def dfs(v,cnt):
    dist[v]=cnt
    for nv in graph[v]:
        if dist[nv]<=cnt+1:
            continue 
        guide[nv]=v
        dfs(nv,cnt+1)

n,m=map(int,input().split())
graph=[[] for _ in range(n+1)]
dist=[float("inf") for _ in range(n+1)]
guide=[0 for _ in range(n+1)]

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

dfs(1,0)

print("Yes")
print(*guide[2:],sep="\n")   

### FIXED CODE ###

import queue
n,m=map(int,input().split())
graph=[[] for _ in range(n+1)]
dist=[-1 for _ in range(n+1)]
guide=[0 for _ in range(n+1)]

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

que=queue.Queue()
dist[1]=0
que.put(1)

while not que.empty():
    v=que.get()
    for nv in graph[v]:
        if dist[nv]!=-1:
            continue
        dist[nv]=dist[v]+1
        guide[nv]=v
        que.put(nv)

print("Yes")
print(*guide[2:],sep="\n")