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

n = int(input())
A=list(map(int, input().split()))
B=sorted([A[i]+i+1 for i in range(n)])
x=B[0]
y=B[-1]
C=sorted([j+1-A[j] for j in range(n) if x<=j+1-A[j]<=y])
C2=set(C)

t=0
for i in range(n):
  if B[i] in C2:
    t+= C.count(B[i])
print(t)


### FIXED CODE ###

n = int(input())
A = list(map(int, input().split()))
L = [i+x for i, x in enumerate(A)]
R = [i-x for i, x in enumerate(A) if i-x > 0]

from collections import Counter
P = Counter(L)
Q = Counter(R)
 
ans = 0
for k, v in P.items():
  if k in Q:
    ans += v*Q[k]
print(ans)
### BUGGY CODE ###

from collections import deque
H, W, K = map(int, input().split())
m = [input() for i in range(H)]
v = [[0]*W for i in range(H)]
f = 0
for i in range(H):
	if f:
		break
	for j in range(W):
		if m[i][j] == "S":
			x = i
			y = j
			f = 1
			break
dq = deque([[x,y,0]])
v[x][y] = 1
ans = (min(x, y, H-1-x, W-1-y)+K-1)//K
while dq:
	x, y, c = dq.popleft()
	v[x][y] = 1
	ans = min(ans, (min(x, y, H-1-x, W-1-y)+K-1)//K)
	if c < K:
		c += 1
		if x > 0 and m[x-1][y] == "." and not v[x-1][y]:
			dq.append([x-1,y,c])
		if x < H-1 and m[x+1][y] == "." and not v[x+1][y]:
			dq.append([x+1,y,c])
		if y > 0 and m[x][y-1] == "." and not v[x+1][y-1]:
			dq.append([x,y-1,c])
		if y < W-1 and m[x][y+1] == "." and not v[x][y+1]:
			dq.append([x,y+1,c])
print(ans+1)

### FIXED CODE ###

from collections import deque
H, W, K = map(int, input().split())
m = [input() for i in range(H)]
v = [[0]*W for i in range(H)]
f = 0
for i in range(H):
	if f:
		break
	for j in range(W):
		if m[i][j] == "S":
			x = i
			y = j
			f = 1
			break
dq = deque([[x,y,0]])
v[x][y] = 1
ans = (min(x, y, H-1-x, W-1-y)+K-1)//K
while dq:
	x, y, c = dq.popleft()
	ans = min(ans, (min(x, y, H-1-x, W-1-y)+K-1)//K)
	if c < K:
		c += 1
		if x > 0 and m[x-1][y] == "." and not v[x-1][y]:
			dq.append([x-1,y,c])
			v[x-1][y] = 1
		if x < H-1 and m[x+1][y] == "." and not v[x+1][y]:
			dq.append([x+1,y,c])
			v[x+1][y] = 1
		if y > 0 and m[x][y-1] == "." and not v[x][y-1]:
			dq.append([x,y-1,c])
			v[x][y-1] = 1
		if y < W-1 and m[x][y+1] == "." and not v[x][y+1]:
			dq.append([x,y+1,c])
			v[x][y+1] = 1
print(ans+1)
### BUGGY CODE ###

N=int(input())
A=list(map(int,input().split()))
count=0
if(N%2==0):
  flag=True
  for i in range(N//2):
    try:
      A.remove(2*i+1)
      try:
        A.remove(2*i+1)
        count+=1
      except:
        flag=False
        break
    except:
      flag=False
      break
else:
  flag=True
  for i in range((N+1)//2):
    if(i==0):
      try:
        A.remove(0)
      except:
        flag=False
        break
    else:
      try:
        A.remove(2*i)
        try:
          A.remove(2*i)
          count+=1
        except:
          flag=False
          break
      except:
        flag=False
        break
if(flag==True):
  print(2**count%(10**9+7))
else:
  print(0)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
count=0
ans=1
A.sort()
if(N%2==0):
  flag=True
  for i in range(N):
    if(i%2==0):
      if(A[i]!=i+1):
        flag=False
        break
    else:
      if(A[i]!=i):
        flag=False
        break
      else:
        ans=(ans*2)%(10**9+7)
else:
  flag=True
  if(A[0]!=0):
    flag=False
  for i in range(N):
    if(i%2==1):
      if(A[i]!=i+1):
        flag=False
        break
    else:
      if(A[i]!=i):
        flag=False
        break
      else:
        if(i>0):
          ans=(ans*2)%(10**9+7)
if(flag==True):
  print(ans)
else:
  print(0)
### BUGGY CODE ###

s = input()
lst = set()
l = len(s)
for i in range(l):
    for j in range(i, l):
        lst.add(s[i:j+1])
lst = list(lst)
lst.sort()
print(lst[int(input()) - 1])

### FIXED CODE ###

def main():
    s = input()
    k = int(input())
    lst = set()
    l = len(s)
    for i in range(l):
        for j in range(i, i + k):
            lst.add(s[i:j+1])
    lst = list(lst)
    lst.sort()
    print(lst[k - 1])
main()
### BUGGY CODE ###

s = list(input())
s.reverse()

while s:
    if s[:5] == list("maerd"):
        del s[:5]
        continue
    elif s[:7] == list("remaerd"):
        del s[:7]
        continue
    elif s[:5] == list("esare"):
        del s[:5]
        continue
    elif s[:6] == list("resare"):
        del s[:6]
        continue
    else:
        break

if s == []:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

a = list(input())
 
while len(a) >= 5:
    if a[-5:] == list('dream'):
        del a[-5:]
        continue
    if a[-7:] == list('dreamer'):
        del a[-7:]
        continue
    if a[-5:] == list('erase'):
        del a[-5:]
        continue
    if a[-6:] == list('eraser'):
        del a[-6:]
        continue
    break
 
if a == []:
    print('YES')
else:
    print('NO')
### BUGGY CODE ###

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

for i in range(1,n):
    while True:
        if a[i] >= a[i-1]:
            break
        else:
            a[i] += 1
            ans += 1
print(ans)



### FIXED CODE ###

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

for i in range(1,n):
    if a[i] >= a[i-1]:
        continue
    else:
        step = a[i-1] - a[i]
        a[i] += step
        ans += step
print(ans)
### BUGGY CODE ###

A,B,Q=map(int,input().split())
s=[int(input()) for _ in range(A)]
t=[int(input()) for _ in range(B)]

#二分探索関数
def bin_search(x,seq):
    a=0
    b=len(seq)-1
    while((b-a)>1):
        center=((a+b)//2)
        if x>=seq[center]:
            a=center
        else:
            b=center
    return seq[a],seq[b]

for i in range(Q):
    x=int(input())
    Nb_s0,Nb_s1=bin_search(x,s)
    Nb_t0,Nb_t1=bin_search(x,t)
    k1=abs(Nb_s0-x)+abs(Nb_t0-Nb_s0)
    k2=abs(Nb_s1-x)+abs(Nb_t0-Nb_s1)
    k3=abs(Nb_s0-x)+abs(Nb_t1-Nb_s0)
    k4=abs(Nb_s1-x)+abs(Nb_t1-Nb_s1)
    k5=abs(Nb_t0-x)+abs(Nb_t0-Nb_s0)
    k6=abs(Nb_t1-x)+abs(Nb_t1-Nb_s1)
    k7=abs(Nb_t0-x)+abs(Nb_t0-Nb_s1)
    k8=abs(Nb_t1-x)+abs(Nb_t1-Nb_s0)
    print(min(k1,k2,k3,k4,k5,k6,k7,k8))

### FIXED CODE ###

inf=10**11
A,B,Q=map(int,input().split())
s=[-inf]+[int(input()) for _ in range(A)]+[inf]
t=[-inf]+[int(input()) for _ in range(B)]+[inf]
x=[[i,int(input())] for i in range(Q)]

x.sort(key=lambda x:x[1])
i,s_i,t_i=0,0,0
ans=[]

for i in range(Q):
    while(1):
        if x[i][1]>=s[s_i]:
            s_i+=1
        else:
            break
    while(1):
        if x[i][1]>=t[t_i]:
            t_i+=1
        else:
            break
    ans.append([x[i][0],x[i][1],s[s_i-1],s[s_i],t[t_i-1],t[t_i]])
ans.sort(key=lambda x:x[0])
for i in range(Q):
    xx=ans[i][1]
    Nb_s0=ans[i][2]
    Nb_s1=ans[i][3]
    Nb_t0=ans[i][4]
    Nb_t1=ans[i][5]

    p1=abs(Nb_s0-xx)
    p2=abs(Nb_s1-xx)
    p3=abs(Nb_t0-xx)
    p4=abs(Nb_t1-xx)
    q1=abs(Nb_t0-Nb_s0)
    q2=abs(Nb_t0-Nb_s1)
    q3=abs(Nb_t1-Nb_s0)
    q4=abs(Nb_t1-Nb_s1)
    print(min(p1+q1,p2+q2,p1+q3,p2+q4,p3+q1,p4+q4,p3+q2,p4+q3))
### BUGGY CODE ###

x, y, a, b, c = list(map(int, input().split()))
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))

P.sort(reverse=True)
Q.sort(reverse=True)
R.sort(reverse=True)

p = P[:x]
q = Q[:y]
r = []

i = 0

def check(z , l):
    return z > l[-1]

while len(p) ** 2 + len(q) ** 2 > 0 and i < len(R):
    if len(p) * len(q) != 0:
        if R[i] > p[-1] or R[i] > q[-1]:
            r.append(R[i])
            if p[-1] > q[-1]:
                q = q[:-1]
            else:
                p = p[:-1]
    elif len(p) != 0:
        if R[i] > p[-1]:
            r.append(R[i])
            p = p[:-1]

    elif len(q) != 0:
        if R[i] > q[-1]:
            r.append(R[i])
            q = q[:-1]
    
    i +=1

print(sum(p)+sum(q)+sum(r))

### FIXED CODE ###

x, y, a, b, c = list(map(int, input().split()))
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)


i, j, k = x, y, 0

def check(z , l):
    return z > l[-1]

while i**2 + j**2 > 0 and k < len(r):
    if i*j != 0:
        if r[k] > p[i-1] or r[k] > q[j-1]:
            if p[i-1] > q[j-1]:
                j -= 1
            else:
                i -= 1
        else:
            break
    elif i > 0:
        if r[k] > p[i-1]:
            i -= 1
        else:
            break

    elif j > 0:
        if r[k] > q[j-1]:
            j -= 1
        else:
            break


    k += 1

print(sum(p[:i])+sum(q[:j])+sum(r[:k]))
### BUGGY CODE ###

import sys

# import bisect
# from collections import Counter, deque, defaultdict
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter

# import math

# from numba import jit

# from scipy import
# import numpy as np
# import networkx as nx

# import matplotlib.pyplot as plt

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, s = list(map(int, readline().split()))
    a = list(map(int, readline().split()))

    dp = [[0] * (s + 1) for _ in range(n)]

    for ai in range(n):
        a_cur = a[ai]
        dp[ai][0] += 1
        if a_cur <= s:
            dp[ai][a_cur] += 1
        for si in range(s + 1):
            dp[ai][si] += dp[ai - 1][si]
            if (si - a_cur) >= 0:
                dp[ai][si] += dp[ai - 1][si - a_cur]

    ans = 0
    for ai in range(n):
        ans += dp[ai][s]

    print(ans%998244353)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys

readline = sys.stdin.readline
MOD = 998244353
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, s = map(int, readline().split())
    a = list(map(int, readline().split()))
    dp = [[0] * (s + 1) for _ in range(n + 1)]
    dp[0][0] = 1

    for i in range(n):
        cur = a[i]
        dp[i + 1][0] += 1
        for j in range(s + 1):
            dp[i + 1][j] += dp[i][j]
            dp[i + 1][j] %= MOD
            nx = cur + j
            if nx <= s:
                dp[i + 1][nx] += dp[i][j]
                dp[i + 1][nx] %= MOD
    ans = 0

    for i in range(1, n + 1):
        ans += dp[i][s]
        ans %= MOD

    print(ans)


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

n,k,q = map(int,input().split())
p = [k]*n
lenP = len(p)

for _ in range(q):
    a = int(input())
    for i in range(lenP):
        if i != a-1:
            p[i] -= 1
        else:
            continue

[print("Yes" if j >= 1 else "No") for j in p]

### FIXED CODE ###

from collections import Counter

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

ac = Counter(a)

for i in range(n):
    p[i] -= 1*(q-ac[i+1])

[print("Yes" if j >= 1 else "No") for j in p]
### BUGGY CODE ###

from collections import OrderedDict
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)

max_b = max(B)
max_c = max(C)

summs_ab = []
summs = []
for a in A:
    for b in B:
        summs_ab.append(a+b)
summs_ab.sort(reverse=True)
summs_ab = summs_ab[0:min(3001, X*Y*Z+1)]

for c in C:
    for sab in summs_ab:
        summs.append(sab+c)
summs.sort(reverse=True)

for s in summs[0:K]:
    print(s)

### FIXED CODE ###

x,y,z,k = map(int,input().split())
lisa = list(map(int,input().split()))
lisb = list(map(int,input().split()))
lisc = list(map(int,input().split()))
lisa.sort(reverse=True)
lisb.sort(reverse=True)
lisc.sort(reverse=True)
an = []
ans = []
for num in lisb:
    for nu in lisa:
        an.append(num+nu)
an.sort(reverse=True)
an = an[:min(3001,x*y*z+1)]
for num in lisc:
    for nu in an:
        ans.append(num+nu)
ans.sort(reverse=True)
for i in range(k):
    print(ans[i])
### BUGGY CODE ###

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

master_card = set()
L0, R0 = map(int, input().split())
master_card |= set(range(L0, R0 + 1))

for i in range(1, M):
    Li, Ri = map(int, input().split())
    master_card &= set(range(Li, Ri + 1))

print(len(master_card))


### FIXED CODE ###

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

shita = 1
ue = 100000
for i in range(0, M):
    Li, Ri = map(int, input().split())
    if shita < Li:
        shita = Li
    if Ri < ue:
        ue = Ri

print(max(ue - shita + 1, 0))
### BUGGY CODE ###

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

for i in range(n):
	if i==0:
		conf = [A[i]]
		ans = 0
	else:
		add = max(conf)
		ans+= add
		conf.remove(add)
		conf+=[A[i], A[i]]
	#print(conf, ans)

print(ans)

### FIXED CODE ###

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

'''for i in range(n):
	if i==0:
		conf = {A[i]:1}
		ans = 0
	else:
		add=max(conf.keys())
		ans+=add
		conf[A[i]] =2
		if conf[add] >1:
			conf[add] -= 1
		else:
			conf.pop(add)'''

if n%2==0:
	print(sum(A[:n//2]) *2 -A[0])
else:
	print(sum(A[:n//2]) *2 -A[0] +A[n//2])
### BUGGY CODE ###

from functools import reduce
from operator import xor

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

def main():
    val = []
    for i in range(A,B+1):
        val.append(i)
    #print(val)
    ans = reduce(xor,val)
    #print(ans)
    return ans

print(main())


### FIXED CODE ###

from functools import reduce
from operator import xor

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


def calc(A):
    A = A+1
    cnt = 0
    ans = 0
    for i in range(0,50):
        # i=0 2回周期で1が出現
        # i=1 4回周期で1が出現
        loop = pow(2,i+1)

        #端数を覗いた2の出現回数
        #Aが6 / iが1のときは loop=4
        # 7//4 = 1 * 2^1 = 2
        cnt = (A//loop)*pow(2,i)

        # 端数を計算
        # 7%4 - 4/2 = 3-2 = 1
        # 端数は1なので加算
        if((A%loop - loop//2) > 0):
            cnt = cnt + (A%loop - loop//2)

        # cntが奇数の場合は ans 2^iをに加算
        if(cnt%2 == 1):
            ans = ans + pow(2,i)

    return ans



def main():
    return calc(A-1)^calc(B)

print(main())
### BUGGY CODE ###

def f(n):
  if n==0:return 0
  else:return f(pc[n])+1
n=int(input())
x=input()
pc=[0]
m=2*10**5
for i in range(1,m+2):
  cnt=0
  j=i
  while i:
    cnt+=i%2
    i//=2
  pc+=[j%cnt]
cnt=x.count('1')
ix=int(x,2)
d=2**(n-1)
for i in range(n):
  if x[i]=='0':print(f((ix+d)%(cnt+1))+1)
  else:
    if ix-d>m:print(f((ix-d)%(cnt-1))+1)
    else:print(f(ix-d))
  d//=2

### FIXED CODE ###

n=int(input())
x=input()
pc=[0]
m=2*10**5
for i in range(1,m+2):
  cnt=0
  j=i
  while i:
    cnt+=i%2
    i//=2
  pc+=[j%cnt]
f=[0]*(m+2)
for i in range(1,m+2):
  if pc[i]==0:f[i]=1
  else:f[i]=f[pc[i]]+1
cnt=x.count('1')
ix=int(x,2)
ixp=ix%(cnt+1)
ixm=ix%(cnt-1) if cnt-1 else 0
d=1<<(n-1)
for i in range(n):
  dp=pow(2,n-i-1,cnt+1)
  if cnt-1:dm=pow(2,n-i-1,cnt-1)
  if x[i]=='0':print(f[(ixp+dp)%(cnt+1)]+1)
  else:
    if cnt-1:print(f[(ixm-dm)%(cnt-1)]+1)
    else:print(0)
### BUGGY CODE ###

import sys
input=sys.stdin.readline
K,S=map(int,input().split());c=0
for x in range(K+1):
  for y in range(K+1):
    for z in range(K+1):
      if x+y+z == S:
        c+=1
print(c)

### FIXED CODE ###

import sys
input=sys.stdin.readline
K,S=map(int,input().split());c=0
for x in range(K+1):
  for y in range(K+1):
    z = S-x-y
    if 0<=z<=K:
      c+=1
print(c)
### BUGGY CODE ###

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



ables_list = np.zeros(N)

for i in range(M):
    L, R = map(int, input().split())
    L -= 1
    ables_list[L: R] += 1

count = 0
for i in range(N):
    if ables_list[i] == M:
        count += 1

print(count)

### FIXED CODE ###

#   C



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


mini, maxi = map(int, input().split())

for i in range(1, M):
    L, R = map(int, input().split())
    if L > mini:
        mini = L
    if R < maxi:
        maxi = R
    if mini > maxi:
        break
#    print(mini, L, R, maxi)
if mini > maxi:
    print(0)
else:
    print(maxi - mini + 1)
### BUGGY CODE ###

def main():
    h,w=map(int,input().split())
    a=[list(map(int,input().split())) for i in range(h)]
    b=[list(map(int,input().split())) for i in range(h)]


    x=[[abs(a[i][j]-b[i][j]) for j in range(w)] for i in range(h)]
    
    p=x[0][0]

    """
    tmp=[ x[0][j] for j in range(1,w)]
    for i in range(1,h):
        tmp+=x[i]
    tmp.sort(reverse=True)
    
    L=p+sum(tmp[:h+w-2])+1
    """
    state=[[set() for j in range(w)] for i in range(h)]


    state[0][0].add(x[0][0])

    for j in range(1,w):
        p=x[0][j]
        for k in state[0][j-1]:
            state[0][j].add(k+p)
            state[0][j].add(abs(k-p))

    for i in range(1,h):
        p=x[i][0]
        for k in state[i-1][0]:
            state[i][0].add(k+p)
            state[i][0].add(abs(k-p))

    for i in range(1,h):
        for j in range(1,w):
            p=x[i][j]
            for k in state[i][j-1]:
                state[i][j].add(k+p)
                state[i][j].add(abs(k-p))
            for k in state[i-1][j]:
                state[i][j].add(k+p)
                state[i][j].add(abs(k-p))

    print(min(state[h-1][w-1]))

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    h,w=map(int,input().split())
    L=80*(h+w)+1
    a=[list(map(int,input().split())) for i in range(h)]
    b=[list(map(int,input().split())) for i in range(h)]


    x=[[abs(a[i][j]-b[i][j]) for j in range(w)] for i in range(h)]
    

    L=12800
    
    state=[[0]*w for _ in range(h)]
    delta=x[0][0]
    state[0][0]=(2**L>>delta)|(2**L<<delta)

    for j in range(1,w):
        delta=x[0][j]
        state[0][j]=(state[0][j-1]>>delta)|(state[0][j-1]<<delta)

    for i in range(1,h):
        delta=x[i][0]
        state[i][0]=(state[i-1][0]>>delta)|(state[i-1][0]<<delta)

    for i in range(1,h):
        for j in range(1,w):
            delta=x[i][j]
            state[i][j]=(state[i][j-1]>>delta)|(state[i][j-1]<<delta)
            state[i][j]|=(state[i-1][j]>>delta)|(state[i-1][j]<<delta)

    
    ans = 10**9
    for i in range(L*2):
        if state[h-1][w-1] & 1:
            ans = min(ans,abs(i-L))
        state[h-1][w-1]>>=1
    print(ans)



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


def merge(A, left, mid, right):
    n1 = mid - left
    n2 = right - mid
    
    L = []
    R = []

    for i in range(n1):
        L.append(A[left + i])

    for j in range(n2):
        R.append(A[mid + j])

    L.append(float("inf"))
    R.append(float("inf"))

    i = 0
    j = 0

    for k in range(left, right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1

    return right - left

def mergeSort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        cnt1 = mergeSort(A, left, mid)
        cnt2 = mergeSort(A, mid, right)
        cnt3 = merge(A, left, mid, right)
        return cnt1 + cnt2 + cnt3
    else:
        return 0

n = int(input())
S = [int(s) for s in input().split()]

ans = mergeSort(S, 0, n)

print(*S)
print(ans)

### FIXED CODE ###


def merge(A, left, mid, right):
    n1 = mid - left
    n2 = right - mid
    
    L = A[left:mid] + [float("inf")]
    R = A[mid:right] + [float("inf")]

    i = 0
    j = 0

    for k in range(left, right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1

    return right - left

def mergeSort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        cnt1 = mergeSort(A, left, mid)
        cnt2 = mergeSort(A, mid, right)
        cnt3 = merge(A, left, mid, right)
        return cnt1 + cnt2 + cnt3
    else:
        return 0

n = int(input())
S = [int(s) for s in input().split()]

ans = mergeSort(S, 0, n)

print(*S)
print(ans)
### BUGGY CODE ###

#2
n = int(input())
a = list()
for i in range(1,n + 1):
    if i**2 <= n:
        a = a + [i]
    else : 
        break
print(int(a[-1])**2)

### FIXED CODE ###

#2
n = int(input())
print(int(n**(1/2))**2)
### BUGGY CODE ###

n = int(input())
x = list(map(int, input().split()))
ans = x[0]
if 0 in x:
	ans = 0
else:
	for i in range(1,n):
		ans = ans * x[i]
		if ans > 10 ** 18:
			ans = -1
print(ans)

### FIXED CODE ###

n = int(input())
x = list(map(int, input().split()))
ans = x[0]
if 0 in x:
	ans = 0
else:
	for i in range(1,n):
		ans = ans * x[i]
		if ans > 10 ** 18:
			ans = -1
			break
print(ans)
### BUGGY CODE ###

import sys,time
sys.setrecursionlimit(10**6)

def LI(): return [int(x) for x in sys.stdin.readline().split()]


def main():
    start = time.time()
    n,m = LI()
    a = [LI() for _ in range(m)]
    e = [[] for _ in range(n)]
    for l,r,d in a:
        e[l-1].append((r-1,d))
        e[r-1].append((l-1,-d))

    b = [False] * n
    def g(i,c):
        if time.time() - start > 0.9:
            return True
        if c == False:
            c = 0
        b[i] = c
        for r,d in e[i]:
            if b[r] != False:
                if b[r] != c+d:
                    return False
            else:
                if not g(r,c+d):
                    return False
        return True

    for i in range(n):
        if b[i] != False:
            continue
        if not g(i,False):
            return 'No'
    return 'Yes'


print(main())





### FIXED CODE ###

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,m = LI()
    e = [[] for _ in range(n)]
    if m > 0:
        for _ in range(m):
            l,r,d = LI()
            e[l-1].append((r-1,d))
            e[r-1].append((l-1,-d))

    b = [None] * n

    for i in range(n):
        if not b[i] is None:
            continue
        b[i] = 0
        q = [i]
        qi = 0
        nq = []
        while True:
            if len(q) == qi:
                if not nq:
                    break
                q = nq
                qi = 0
                nq = []
            j = q[qi]
            qi += 1
            c = b[j]
            for r,d in e[j]:
                if b[r] is None:
                    b[r] = c+d
                    nq.append(r)
                else:
                    if b[r] != c+d:
                        return 'No'

    return 'Yes'


print(main())
### BUGGY CODE ###

def main():
	import sys

	MAX = 1000000

	table = [True]*1000000
	table[0] = table[1] = False

	primes = []
	counted = 0

	for line in sys.stdin:
		n = int(line)
		if n > counted:
			for i in range(int(n+1)):
				if table[i] and not i in primes:
					primes.append(i)
					for j in range(2*i, MAX, i):
						table[j] = False
			counted = n

		cnt = 0
		for prime in primes:
			if prime > n:
				break
			else:
				cnt += 1
		print(primes)
		print(cnt)


if __name__ == '__main__':
	main()

### FIXED CODE ###

def main():
	import sys

	MAX = 1000000

	table = [True]*1000000
	table[0] = table[1] = False

	primes = []
	counted = 0

	for i in range(MAX):
		if table[i]:
			primes.append(i)
			for j in range(2*i, MAX, i):
				table[j] = False

	for line in sys.stdin:
		n = int(line)

		cnt = 0
		for prime in primes:
			if prime > n:
				break
			else:
				cnt += 1
		print(cnt)


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

n = int(input())
s = []
for i in range(n):
    s.append(''.join(sorted(input())))
ans = 0
s1 = set(s)
for i in s1:
    n = s.count(i) - 1
    ans += n * (n+1) / 2
print(int(ans))


### FIXED CODE ###

import collections
 
N = int(input())
s = ["".join(sorted(input())) for _ in range(N)]
c = collections.Counter(s)
ans = 0
for si in set(s):
    n = c[si]
    ans += n * (n - 1) // 2
print(ans)
### BUGGY CODE ###

N=int(input())
M=[int(_) for _ in input().split()]
a=1
for s in M:
    a=a*s
if a>10**18:
    print(-1)
else:print(a)

### FIXED CODE ###

N=int(input())
M=[int(_) for _ in input().split()]
M.sort(reverse=True)
a=1
if M[-1]==0:
    print(0)
    exit()

else:
    for s in M:
        a=a*s
        if a>10**18:
            print(-1)
            exit()
print(a)