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

from collections import Counter
import sys

def input():
    return sys.stdin.readline().strip()

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

memo = {}
def make_divisors(n):
    if n in memo:
        return memo[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
    
    memo[n] = lower_divisors + upper_divisors[::-1]
    return memo[n]

n,*A = get_all_int()
A.sort()



C = dict(Counter(A))
keys = C.keys()
# log(C)

B = []
for i,a in enumerate(A):
    if C[a] == 1:
        B.append(a)

ans = 0

for i,a in enumerate(B):
    div = make_divisors(a)
    ok = True
    for d in div:
        if d == a:
            continue
        elif d in keys:
            ok = False
            break
    if ok:
        ans += 1

print(ans)


### FIXED CODE ###

from collections import Counter
import sys

def input():
    return sys.stdin.readline().strip()

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

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

n,*A = get_all_int()
A.sort()



C = dict(Counter(A))
keys = C.keys()
# log(C)

checks = [False] * (1000009)

B = []
for i,a in enumerate(A):
    if C[a] == 1:
        B.append(a)
    elif not checks[a]:
        for j in range(a, 1000009, a):
            checks[j] = True

# log(B)

ans = 0

for i,a in enumerate(B):
    if not checks[a]:
        ans += 1
        for j in range(a, 1000009, a):
            checks[j] = True

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

N = int(input())
s = []

to = 0
for i in range(N):
	str = input()
	s.append(sorted(str))
	cnt = s.count(s[i])
	if cnt > 1:
		to += cnt-1

print(to)


### FIXED CODE ###

N = int(input())
s = {}

to = 0
for i in range(N):
	st = input()
	st = str(sorted(st))
	if i == 0 or not st in s:
		s[st] = 1
	elif st in s:
		cnt = s[st]
		to += cnt
		s[st] = cnt + 1

print(to)
### BUGGY CODE ###

import heapq as hq

X, Y, Z, K = map(int, input().split())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

pri = []
data = []
hq.heapify(pri)

A.sort()
B.sort()
C.sort()
A.reverse()
B.reverse()
C.reverse()

hq.heappush(pri, [-A[0]-B[0]-C[0],0,0,0])
data.append([0,0,0])

for i in range(K):
    s = pri[0][1]
    t = pri[0][2]
    u = pri[0][3]
    if s+1 <= X-1:
        if [s + 1, t, u] not in data:
            data.append([s+1, t, u])
            hq.heappush(pri, [-A[s+1]-B[t]-C[u],s+1,t,u])
    if t+1 <= Y-1:
        if [s, t+1, u] not in data:
            data.append([s, t+1, u])
            hq.heappush(pri, [-A[s]-B[t+1]-C[u],s,t+1,u])
    if u+1 <= Z-1:
        if [s, t, u+1] not in data:
            data.append([s, t, u+1])
            hq.heappush(pri, [-A[s]-B[t]-C[u+1],s,t,u+1])
    print(hq.heappop(pri)[0] * -1)

### FIXED CODE ###

import heapq as hq

X, Y, Z, K = map(int, input().split())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

pri = []
data = []
hq.heapify(pri)

A.sort()
B.sort()
C.sort()
A.reverse()
B.reverse()
C.reverse()

hq.heappush(pri, [-A[0]-B[0]-C[0],0,0,0])
data.append([0,0,0])

for i in range(K):
    s = pri[0][1]
    t = pri[0][2]
    u = pri[0][3]
    if s+1 <= X-1:
        if [s + 1, t, u] not in data:
            data.append([s+1, t, u])
            hq.heappush(pri, [-A[s+1]-B[t]-C[u],s+1,t,u])
    if t+1 <= Y-1:
        if [s, t+1, u] not in data:
            data.append([s, t+1, u])
            hq.heappush(pri, [-A[s]-B[t+1]-C[u],s,t+1,u])
    if u+1 <= Z-1:
        if [s, t, u+1] not in data:
            data.append([s, t, u+1])
            hq.heappush(pri, [-A[s]-B[t]-C[u+1],s,t,u+1])
    print(hq.heappop(pri)[0] * -1)
### BUGGY CODE ###

x,y = (int(x) for x in input().split())

while True:
  if x == "0" and y == "0":
    break
  if x > y:
    print (str(x) + " " + str(y))
  else:
    print (str(y) + " " + str(x))



### FIXED CODE ###

while True:
  x,y = (int(x) for x in input().split())

  if x == 0 and y == 0:
    break
  if x < y:
    print (str(x) + " " + str(y))
  else:
    print (str(y) + " " + str(x))
### BUGGY CODE ###

#!python3

def resolve():
    N = int(input())
    A = tuple(map(int, input().rstrip().split()))

    a = 0
    for i in range(N-1):
        for j in range(i+1, N):
            a += A[i] ^ A[j]
    print(a % (10**9+7))

if __name__ == "__main__":
    resolve()


### FIXED CODE ###

#!python3

def resolve():
    N = int(input())
    A = tuple(map(int, input().rstrip().split()))

    ma = max(*A)

    i = 1
    asum = 0
    while i < ma:
        cc = 0
        for x in A:
            if x & i: cc += 1
        asum += i * (N - cc) * cc
        i <<= 1

    print(asum % (10**9+7))

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

N = int(input())
A = list(map(int, input().split()))
times = 1
for i in A:
    times *= i
if times > 10**18:
    print(-1)
else:
    print(times)

### FIXED CODE ###

def m():  
    N = int(input())
    A = list(map(int, input().split()))
    times = 1
    c = 0

    for i in A: 
        if times <= 10**18 and c < N:
            times *= i
            c += 1   
    if times > 10 ** 18:
        times = -1
    if 0 in A:
        times = 0
    print(times)
m()
### BUGGY CODE ###

n,k = [ int(i) for i in input().split(" ")]
arr = [ int(i) for i in input().split(" ")]

tmp = []
for i in range(len(arr)):
  for j in range(i+1, len(arr)):
    tmp.append(arr[i] * arr[j])

tmp.sort()
print(tmp[k-1])

### FIXED CODE ###

from bisect import bisect_left, bisect_right
N,K = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
neg_end = bisect_left(A, 0)
pos_start = bisect_right(A, 0)

pos_cnt = N - pos_start
neg_cnt = neg_end
zero_cnt = N - (pos_cnt + neg_cnt)

neg_pairs_cnt = pos_cnt * neg_cnt
zero_pairs_cnt = zero_cnt * (pos_cnt + neg_cnt) + (zero_cnt * (zero_cnt-1) // 2)

if K <= neg_pairs_cnt:
  # X以下のpairはK個以上あるか？
  ok, ng = 0, -10**18
  while abs(ok - ng) > 1:
    X = (ok+ng) // 2
    or_higher_cnt, r = 0, pos_start
    # それぞれのnegごとに尺取り法
    for l in range(neg_end):
      while r < N and A[l] * A[r] > X:
        r += 1
      # positive_integers - (max_point - positive_start_index)
      or_higher_cnt += pos_cnt - (r - pos_start)

    if or_higher_cnt >= K:
      ok = X
    else:
      ng = X
  print(ok)

elif K <= neg_pairs_cnt + zero_pairs_cnt:
  print(0)

else:
  K -= (neg_pairs_cnt + zero_pairs_cnt)
  ok, ng = 10**18, 0
  while abs(ok - ng)> 1:
    X = (ok+ng) // 2
    or_higher_cnt = 0

    r = N - 1
    for l in range(pos_start, N):
      while r < N and A[l] * A[r] > X and l < r:
        r -= 1
      or_higher_cnt += max(0, r-l)

    l = 0
    for r in range(neg_end-1, -1, -1):
      while l < N and A[l] * A[r] > X and l < r:
        l += 1
      or_higher_cnt += max(0, r-l)

    if or_higher_cnt >= K:
      ok = X
    else:
      ng = X

  print(ok)
### BUGGY CODE ###

ans = 1

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

for i in range(n):
    ans *= a[i]

if ans > 1000000000000000000:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

ans = 1
flag = 0

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

if 0 in a:
    print(0)
else:
    for i in range(n):
        ans *= a[i]
        if ans > 1000000000000000000:
            flag = 1
            print(-1)
            break
    
    if flag == 0:
        print(ans)
### BUGGY CODE ###

n,k = map(int, input().split())
a = list(map(int, input().split()))
d = {}
for num,i in enumerate(a):
  d[num+1] =  i
t = []
i = 1
j = 1
while(i not in t):
  t.append(i)
  i = d[i]
for num,j in enumerate(t):
  if j == i:
    b = num
    break
a = 1
if k < b+1:
  ans = t[k]
else:
  k = (k-b)%(len(t)-b)
  ans = t[b+k]
print(ans)

### FIXED CODE ###

n,k = map(int, input().split())
a = list(map(int, input().split()))
d = {}
for num,i in enumerate(a):
  d[num+1] =  i
t = {}
t_ = {}
i = 1
j = 0
while(i not in t):
  t[i] = j
  t_[j] = i
  i = d[i]
  j += 1
a = 1
b = t[i]
if k < b+1:
  ans = t_[k]
else:
  k = (k-b)%(len(t.keys())-b)
  ans = t_[b+k]
print(ans)
### BUGGY CODE ###

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

s=0
if B<=N+1:
  x=B-1
  s=(A*x)//B - A*(x//B)
else:
  for x in range(1,N+1):
    p = (A*x)//B - A*(x//B)
    if p<s:
      break
    if p>s:
      s=p
print(s)

### FIXED CODE ###

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

s=0
if B<=N:
  x=B-1
  s=(A*x)//B - A*(x//B)
else:
  x=N
  s=(A*x)//B - A*(x//B)
print(s)
### BUGGY CODE ###

N = int(input())
S = input()

# len 取り得る最大の長さは N / 2

for i in range(N//2, 0, -1):
  for j in range(0, N-2*i+1):
    left = S[j:j+i]
    if S[j+i:].count(left) >= 1:
        print(len(left))
        exit()
        
print(0)

### FIXED CODE ###

N = int(input())
S = input()


r = 0
ans = 0
for l in range(N):

    while True:
        # print(S.rfind(S[l:r+1]), S[l:r+1], l, r)
        
        if S.rfind(S[l:r+1]) >= r+1:
            r += 1
            ans = max(ans, r-l)
        else:
            break

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

# AtCoder Educational DP Contest
# B Frog 2


def main():
    n, k, *h = map(int, open(0).read().split())

    dp = [0 for _ in range(n)]
    for i, h_now in enumerate(h[1:], 1):
        l = max(0, i - k)
        hs = h[l:i]
        dps = dp[l:i]
        tmp = 10 ** 9
        for x, y in zip(hs, dps):
            cost = abs(h_now - x) + y
            tmp = min(tmp, cost)
        dp[i] = tmp

    res = dp[-1]
    print(res)


if __name__ == '__main__':
    main()


### FIXED CODE ###

n, k = map(int, input().split())
hs = list(map(int, input().split()))
dp=[0]*n
dp[0]=0
for i, hi in enumerate(hs):
    if i == 0:
        continue
    s = max(0, i-k)
    dp[i] = min([ml + abs(hl - hi) for ml, hl in zip(dp[s:i], hs[s:i])])
print(dp[-1])
### BUGGY CODE ###

fact_list=[None]*300001
inv_fact_list=[None]*300001
fact_list[0]=1
inv_fact_list[0]=1
"""
def inv(n):
    if inv_fact_list[n]!=None:
        return inv_fact_list[n]
    m=fact_list[n]
    s=1
    for i in range(30):
        if i!=23 and i!=26:
            s=(s*m)%998244353
        m=(m**2)%998244353
    inv_fact_list[n]=s
    return s
def enc(n):
    if n==0:
        return "("
    s=""
    while n>0:
        s+=chr(n%86+40)
        n//=86
    return s

def dec(s):
    n=0
    for i in range(len(s)):
        n+=(86**i)*(ord(s[i])-40)
    return n
"""
def comb(n,r):
    if r==0 or r==n:
        return 1
    if r==1 or r==n-1:
        return n
    if inv_fact_list[n-r]!=None:
        invnr=inv_fact_list[n-r]
    else:
        m=fact_list[n-r]
        invnr=1
        for i in range(30):
            if i!=23 and i!=26:
                invnr=(invnr*m)%998244353
            m=(m**2)%998244353
        inv_fact_list[n-r]=invnr
    if inv_fact_list[r]!=None:
        invr=inv_fact_list[r]
    else:
        m=fact_list[r]
        invr=1
        for i in range(30):
            if i!=23 and i!=26:
                invr=(invr*m)%998244353
            m=(m**2)%998244353
        inv_fact_list[r]=invr
    return (((fact_list[n]*invnr)%998244353)*invr)%998244353

for i in range(1,300001):
    fact_list[i]=(fact_list[i-1]*i)%998244353

s=input().split()
n,a,b,k=int(s[0]),int(s[1]),int(s[2]),int(s[3])
res=0
for i in range(n+1):
    if k-a*i<0:
        break
    if (k-a*i)%b==0 and 0<=(k-a*i)//b<=n:
        res=(res+comb(n,i)*comb(n,(k-a*i)//b))%998244353
print(res)


### FIXED CODE ###

fact_list=[None]*300001
inv_fact_list=[None]*300001
fact_list[0]=1
inv_fact_list[0]=1
"""
def inv(n):
    if inv_fact_list[n]!=None:
        return inv_fact_list[n]
    m=fact_list[n]
    s=1
    for i in range(30):
        if i!=23 and i!=26:
            s=(s*m)%998244353
        m=(m**2)%998244353
    inv_fact_list[n]=s
    return s
def enc(n):
    if n==0:
        return "("
    s=""
    while n>0:
        s+=chr(n%86+40)
        n//=86
    return s
 
def dec(s):
    n=0
    for i in range(len(s)):
        n+=(86**i)*(ord(s[i])-40)
    return n
"""
def comb(n,r):
    if r==0 or r==n:
        return 1
    if r==1 or r==n-1:
        return n
    if inv_fact_list[n-r]!=None:
        invnr=inv_fact_list[n-r]
    else:
        m=fact_list[n-r]
        invnr=1
        for i in range(30):
            if i!=23 and i!=26:
                invnr=(invnr*m)%998244353
            m=(m**2)%998244353
        inv_fact_list[n-r]=invnr
    if inv_fact_list[r]!=None:
        invr=inv_fact_list[r]
    else:
        m=fact_list[r]
        invr=1
        for i in range(30):
            if i!=23 and i!=26:
                invr=(invr*m)%998244353
            m=(m**2)%998244353
        inv_fact_list[r]=invr
    return (((fact_list[n]*invnr)%998244353)*invr)%998244353
 
for i in range(1,300001):
    fact_list[i]=(fact_list[i-1]*i)%998244353
 
s=input().split()
n,a,b,k=int(s[0]),int(s[1]),int(s[2]),int(s[3])
res=0
for i in range(n+1):
    if k-a*i<0:
        break
    if (k-a*i)%b==0 and 0<=(k-a*i)//b<=n:
        res=(res+comb(n,i)*comb(n,(k-a*i)//b))%998244353
print(res)
### BUGGY CODE ###

n, w = map(int, input().split())
shina = tuple(tuple(map(int, input().split())) for _ in range(n))

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

for i, wv in enumerate(shina):
    wi = wv[0]
    vi = wv[1]
    dpi = dp[i]

    for sum_w in range(w+1):
        if sum_w - wi >= 0:
            dp[i+1][sum_w] = max(dp[i+1][sum_w], dpi[sum_w - wi] + vi)

        dp[i+1][sum_w] = max(dp[i+1][sum_w], dpi[sum_w])

print(dp[-1][-1])

### FIXED CODE ###

import numpy as np
n, w = map(int, input().split())
wv_list = [[int(i) for i in input().split()] for i in range(n)]

dp = np.zeros(w+1)
for wv in wv_list:
    w = wv[0]
    v = wv[1]
    dp[w:] = np.maximum(dp[:-w]+v, dp[w:])

print(int(np.max(dp)))
### BUGGY CODE ###

n = int(input())
kehin = []
for i in range(n):
    s = input()
    if not s in kehin:
        kehin.append(s)
print(len(kehin))


### FIXED CODE ###

n = int(input())
kehin = []
for i in range(n):
    s = input()
    kehin.append(s)
kehin = set(kehin)
print(len(kehin))
### BUGGY CODE ###

from itertools import combinations_with_replacement

n = int(input())

for i in range(1, n+1):
    ans = 0
    for v in combinations_with_replacement(range(1, 60), 3):        
        x, y, z = v

        if x**2 + y**2 + z**2 + x*y + y*z + z*x == i:
            if x == y == z:
                ans = 1
            else:
                ans = 3
            break
            
    print(ans)

### FIXED CODE ###

n = int(input())
ans = [0] * (n+1)

for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            s = x*x + y*y + z*z
            s += x*y + y*z + z*x
            if (s > n):
                continue
            else:
                ans[s] += 1

for i in range(1, n+1):
    print(ans[i])
### BUGGY CODE ###

K = int(input())
A,B = list(map(int, input().split()))
flag = 0
while(flag==0):
  if(A<=K and K<=B):
    flag = 1
    break
  K += K
if(flag==0):
  print("NG")
else:
  print("OK")

### FIXED CODE ###

K = int(input())
A,B = list(map(int, input().split()))
num = K
flag = 0
while(flag==0):
  if(A<=num and num<=B):
    flag = 1
    break
  num += K
  if(num>B):
    break
if(flag==0):
  print("NG")
else:
  print("OK")
### BUGGY CODE ###

import numpy as np
 
n, k, q = map(int, input().split())
a = list(int(input()) for i in range(q))
 
for i in range(n):
  cnt = a.count(i+1)
  if k - q + cnt > 0:
    print('Yes')
  else:
    print('No')

### FIXED CODE ###

import numpy as np

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

score = [k - q]*(n+1)

for i in range(q):
  score[a[i]] += 1

for i in range(1,n+1):
  if score[i] > 0:
    print('Yes')
  else:
    print('No')
### BUGGY CODE ###

N, M = map(int, input().split())
a, b, c = [0] * M, [0] * M, [0] * M
d = [-1e20] * N
for i in range(M):
    a[i], b[i], c[i] = map(int, input().split())
    a[i] -= 1
    b[i] -= 1

d[0] = 0
for i in range(N-1):
    for j in range(M):
        d[b[j]] = max((d[b[j]], d[a[j]] + c[j]))

isCycle = False
for i in range(N-1):
    if isCycle:
        break
    for j in range(M):
        if b[j] == N-1 and d[b[j]] < d[a[j]] + c[j]:
            isCycle = True
            break
        d[b[j]] = max((d[b[j]], d[a[j]] + c[j]))
if isCycle:
    print('inf')
else:
    print(d[N-1])


### FIXED CODE ###

N, M = map(int, input().split())
a, b, c = [0] * M, [0] * M, [0] * M
INF = int(1e13) + 1
for i in range(M):
    a[i], b[i], c[i] = map(int, input().split())
    a[i] -= 1
    b[i] -= 1

d = [-INF] * N
d[0] = 0
for __x in range(N-1):
    for i in range(M):
        if d[b[i]] < d[a[i]] + c[i]:
            d[b[i]] = d[a[i]] + c[i]

isCycle = False
for __x in range(N-1):
    if isCycle:
        break
    for i in range(M):
        if d[b[i]] < d[a[i]] + c[i]:
            d[b[i]] = d[a[i]] + c[i]
            if b[i] == N-1:
                isCycle = True
                break

if isCycle:
    print('inf')
else:
    print(d[N-1])
### BUGGY CODE ###

N,K=map(int,input().split())
a=list(map(int,input().split()))
d=[0]*N
ans=0
for i in range(N):
    d[a[i]-1]+=1
d.sort(reverse=True)
while len(d)>K:
    if i!=0:
        ans += d[K]
        d.pop(K)
    else:
        break
print(ans)

### FIXED CODE ###

N,K=map(int,input().split())
a=list(map(int,input().split()))
d=[0]*N
ans=0
for i in range(N):
    d[a[i]-1]+=1
d.sort(reverse=True)
if len(d)>K:
    ans =sum(d[K:])
print(ans)
### BUGGY CODE ###

n = int(input())
a, b, c = [list(map(int, input().split(" "))) for i in range(3)]

a.sort()
b.sort()
c.sort()

count = 0
for a_i in a:
    for b_i in b:
        for c_i in c:
            if a_i < b_i < c_i:
                count += 1
print(count)

### FIXED CODE ###

import bisect

n = int(input())
abc = [tuple(map(int, input().split(" "))) for i in range(3)]
# n = 100000
# abc = [tuple(range(n)) for i in range(3)]

a, b, c = [sorted(abc_i) for abc_i in abc]

print(sum(bisect.bisect_left(a, b_i) * (n-bisect.bisect(c, b_i)) for b_i in b))
### BUGGY CODE ###

mod = 10**9+7
S = [int(x) if x != "?" else -1 for x in input()]

dp = [[0] * 13 for i in range(len(S)+1)]
dp[0][0] = 1

for i in range(len(S)):
    if S[i] == -1:
        for d in range(10):
            for j in range(13):
                dp[i+1][(j*10+d) % 13] += dp[i][j]
    else:
        d = S[i]
        for j in range(13):
            dp[i+1][(j*10+d) % 13] += dp[i][j]

    # for k in range(13):
    #     dp[i+1][k] = dp[i+1][k] % mod

    # print(dp)

print(dp[len(S)][5] % mod)


### FIXED CODE ###

mod = 10**9+7
S = [int(x) if x != "?" else -1 for x in input()]

dp = [[0] * 13 for i in range(len(S)+1)]
dp[0][0] = 1

for i in range(len(S)):
    if S[i] == -1:
        for d in range(10):
            for j in range(13):
                dp[i+1][(j*10+d) % 13] += dp[i][j]
    else:
        d = S[i]
        for j in range(13):
            dp[i+1][(j*10+d) % 13] += dp[i][j]

    for k in range(13):
        dp[i+1][k] = dp[i+1][k] % mod

    # print(dp)

print(dp[len(S)][5])
### BUGGY CODE ###

n, m, q = map(int, input().split())
import numpy as np
Arr = np.zeros((n+1)**2, dtype=np.int).reshape((n+1, n+1))
for i in range(m):
  l, r = map(int, input().split())
  Arr[l][r] += 1
#print(Arr)

for i in range(q):
  left, right = map(int, input().split())
  train_num = np.sum(Arr[left:right+1, left:right+1], axis=None, dtype=np.int)
  print(train_num)


### FIXED CODE ###

n, m, q = map(int, input().split())
Arr = []
for i in range(n+1):
  Arr.append([0] * (n+1))
for i in range(m):
  l, r = map(int, input().split())
  Arr[l][r] += 1
#print(Arr)

B = []
for i in range(n+1):
  B_line = [0]
  for j in range(1, n+1):
    B_line.append(B_line[-1] + Arr[i][j])
  B.append(B_line)
#print(B)
  
for x in range(q):
  left, right = map(int, input().split())
  train_num = 0
  for i in range(left, right+1):
    train_num += B[i][right] - B[i][left-1]
  print(train_num)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

def main():
    N = int(input())
    A = [int(v) for v in input().split()]

    ans = 1
    for a in A:
        ans *= a
    
    if ans > 1e18:
        print(-1)
    else:
        print(ans)

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
input = sys.stdin.readline

def main():
    N = int(input())
    A = sorted([int(v) for v in input().split()])

    over = False
    ans = 1
    for a in A:
        ans *= a
        if ans > 1e18:
            over = True
            break
    
    if over:
        print(-1)
    else:
        print(ans)

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

import sys

input = sys.stdin.readline
n, m = map(int, input().split())
A = list(map(int, input().split()))
B = 0
for _ in range(m):
    b, c = map(int, input().split())
    B += b
    C = [c]*b
    A.extend(C)

A.sort()
del A[0:B]
print(sum(A))

### FIXED CODE ###

import sys

input = sys.stdin.readline
n, m = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for _ in range(m)]
BC.sort(key=lambda x: -x[1])

maxi = n*2
extend = A.extend
[extend([ls[1]] * ls[0]) for ls in BC if len(A) <= maxi]
A.sort(reverse=True)

print(sum(A[:n]))
### BUGGY CODE ###

def main():
	s = str(input())
	q = int(input())
	qu = [list(map(str,input().split())) for x in range(q)]
	shiji = 1
	rcount = 0
	for i in range(q):
		if qu[i][0] != '1':
			if shiji == 1:
				if qu[i][1] == '1':
					s = qu[i][2] + s
				else:
					s = s + qu[i][2]
			else:
				if qu[i][1] == '2':
					s = qu[i][2] + s
				else:
					s = s + qu[i][2]
		else:
			shiji *= -1
			rcount += 1
	if rcount % 2 == 0:
		print(s)
	else:
		print(s[::-1])

if __name__ == '__main__':
	main()

### FIXED CODE ###

def main():
	s = str(input())
	q = int(input())
	shiji = 1
	rcount = 0
	from collections import deque
	s = deque(s)
	for i in range(q):
		qu = list(map(str,input().split()))
		if qu[0] != '1':
			if shiji == 1:
				if qu[1] == '1':
					s.appendleft(qu[2])
				else:
					s.append(qu[2])
			else:
				if qu[1] == '2':
					s.appendleft(qu[2])
				else:
					s.append(qu[2])
		else:
			shiji *= -1
			rcount += 1
	if rcount % 2 == 0:
		print(''.join(map(str,s)))
	else:
		s.reverse()
		print(''.join(map(str,s)))

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

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

S = [0]

for i in range(n):
    S.append(S[i] + nums[i])

S.sort()


ans = 0

for i in range(n):
    for j in range(i+1, n+1):
        if S[i] == S[j]:
            ans += 1
        elif S[i] > S[j]:
            break

print(ans)

### FIXED CODE ###

from collections import Counter
n = int(input())
nums = list(map(int,input().split()))

S = [0]

for i in range(n):
    S.append(S[i] + nums[i])

S.sort()
ans = 0
p = S[0]
c = Counter(S)

for i in range(1, n+1):
    if i == n or S[i] != p:
        x = c[p]
        ans += x * (x-1) // 2
        p = S[i]


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

iN,iA =[int(x) for x in input().split()]
#aX = [int(x) - iA for x in input().split()]
aX = [int(x) for x in input().split()]

#解法1
#すげーな動的計画法
iMX = max(aX + [iA])
dp = [[[0]*(iN*iMX + 1) for _ in range(iN+1)] for _ in range(iN + 1)]

dp[0][0][0] = 1
for j in range(1,iN+1):
    for k in range(0,iN+1):
        for s in range(0,iN*iMX + 1):
            if  s < aX[j-1]:
                dp[j][k][s] = dp[j-1][k][s]
            elif k >= 1 and  s >= aX[j-1]:
                dp[j][k][s] = dp[j-1][k][s]+dp[j-1][k-1][s- aX[j-1]]
            else:
                dp[j][k][s] = 0
iRet = 0
for k in range(1,iN+1):
    iRet += dp[iN][k][k*iA]
print(iRet)


### FIXED CODE ###

iN,iA =[int(x) for x in input().split()]
aX = [int(x) - iA for x in input().split()]

#解法2

iMX = max(aX + [iA])
dp = [[0]*(2 * iN*iMX + 1) for _ in range(iN+1)]

for j in range(0,iN+1):
    for t in range(0,2*iN*iMX):
        if j == 0 and t == iN * iMX :
            dp[j][t] = 1
        elif j >= 0 and ( t - aX[j-1] < 0 or t - aX[j-1] > 2*iN*iMX):
            dp[j][t] = dp[j-1][t]
        elif j >= 0 and ( 0 <= t - aX[j-1] <= 2*iN*iMX):
            dp[j][t] = dp[j-1][t] + dp[j-1][t-aX[j-1]]
        else:
            dp[j][t] = 0
print(dp[iN][iN*iMX] -1 )