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


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

for i in range(0,n-1):
    for o in range(1,n,2):
        if a[i]+a[o] == o-i:
            count += 1
        if (o+1 <= n-1) and (a[i]+a[o+1] == o+1-i):
            count += 1

print(count)

### FIXED CODE ###


from collections import defaultdict

n = int(input())
a = list(map(int, input().split()))
lInfo = defaultdict(int)
rInfo = defaultdict(int)
cnt = 0

for i in range(n):
    lInfo[a[i]+i] += 1
    rInfo[i-a[i]] += 1

for k in lInfo.keys():
    cnt += lInfo[k] * rInfo[k]
print(cnt)
### BUGGY CODE ###

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

### FIXED CODE ###

from collections import Counter
n = int(input())
a = []
for _ in range(n):
  i = int(input())
  a.append(i)
col = Counter(a)
ans = 0
for c in col.values():
	if c % 2 == 1: ans += 1
print(ans)
### BUGGY CODE ###

import sys
from collections import deque

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    H, W = map(int, input().split())
    S = [list(input()) for _ in range(H)]

    res = 0
    for sh in range(H):
        for sw in range(W):
            if S[sh][sw] != "#":
                for gh in range(H):
                    for gw in range(W):
                        if S[gh][gw] != "#":
                            maze = [[f_inf] * W for _ in range(H)]
                            maze[sh][sw] = 0
                            que = deque([[sh, sw]])
                            while que:
                                h, w = que.popleft()
                                for dh, dw in [(1, 0), (-1, 0), (0, 1), (0, -1)]:
                                    next_h, next_w = h + dh, w + dw
                                    if next_h < 0 or next_h >= H or next_w < 0 or next_w >= W:
                                        continue
                                    elif S[next_h][next_w] == "#":
                                        continue
                                    else:
                                        if maze[next_h][next_w] > maze[h][w] + 1:
                                            maze[next_h][next_w] = maze[h][w] + 1
                                            que.append([next_h, next_w])
                            if maze[gh][gw] != f_inf:
                                res = max(res, maze[gh][gw])
    print(res)


if __name__ == '__main__':
    resolve()


### FIXED CODE ###

from collections import deque

H, W = map(int, input().split())
grid = [input() for _ in range(H)]

f_inf = float('inf')
ans = []
for h in range(H):
    for w in range(W):
        if grid[h][w] == "#":
            continue
        else:
            maze = [[f_inf] * W for _ in range(H)]
            sh, sw = h, w
            maze[sh][sw] = 0
            que = deque([[sh, sw]])
            while que:
                h, w = que.popleft()
                for dh, dw in ((1, 0), (-1, 0), (0, 1), (0, -1)):
                    next_h, next_w = h + dh, w + dw
                    if next_h < 0 or next_h >= H or next_w < 0 or next_w >= W:
                        continue
                    elif grid[next_h][next_w] == "#":
                        continue
                    elif grid[next_h][next_w] == ".":
                        if maze[next_h][next_w] > maze[h][w] + 1:
                            maze[next_h][next_w] = maze[h][w] + 1
                            que.append([next_h, next_w])
                            ans.append(maze[next_h][next_w])

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

N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = []
C = []
for i in range(Q):
    b, c = list(map(int, input().split()))
    B.append(b)
    C.append(c)

total = sum(A)

for i in range(Q):
    count = A.count(B[i])

    d = C[i] - B[i]
    total += count * d
    print(total)

    A = [C[i] if x == B[i] else x for x in A]


### FIXED CODE ###


N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = []
C = []
for i in range(Q):
    b, c = list(map(int, input().split()))
    B.append(b)
    C.append(c)

max_num = max(max(A), max(B), max(C))

NUM = [0] * (max_num + 1)

num_list = []

for a in A:
    NUM[a] += 1

total = sum(A)

for i in range(Q):

    total += (C[i] - B[i]) * NUM[B[i]]
    NUM[B[i]], NUM[C[i]] = 0, NUM[B[i]] + NUM[C[i]]

    print(total)
### BUGGY CODE ###

from fractions import gcd

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

res = 0
for i in range(N):
    tmp = A[i+1:] + A[:i]
    ans = tmp[0]
    for i in range(1,N-1):
        ans = gcd(ans,tmp[i])
    if(res < ans):
        res = ans
print(res)

### FIXED CODE ###

from fractions import gcd

N = int(input())
A = list(map(int,input().split()))
'''
res = 0
for i in range(N):
    tmp = A[i+1:] + A[:i]
    ans = tmp[0]
    for i in range(1,N-1):
        ans = gcd(ans,tmp[i])
    res = max(ans,res)
print(res)
'''

L = [0] * (N+1)
R = [0] * (N+1)

for i in range(N):
    L[i+1] = gcd(L[i],A[i])
    R[N-i-1] = gcd(R[N-i],A[N-i-1])
ans = 0
for i in range(N):
    ans = max(ans,gcd(L[i],R[i+1]))

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

import queue
n = int(input())

#ab = [[]*(n)]
ab = [[] for _ in range(n+1)]
#print(ab)

li = []

for i in range(n-1):
    a,b = map(int,input().split())
    ab[a].append(b)
    ab[b].append(a)
    li.append([a,b])
    
ab_color = [[0 for _ in range(n+1)] for _ in range(n+1)]

#print(li)

q = queue.Queue()
check = [0] * (n+1)
#check[1] == 1
check_color = [0] * (n+1)

q.put(1)
color_num = 1
#mae_color = 0

while not q.empty():
    tmp_color = 0
    tmp = q.get()
    #print(tmp)
    #tmp_color = mae_color
    mae_color = check_color[tmp]
    for i in range(len(ab[tmp])):
        if check[ab[tmp][i]] == 1:
            #print(i,tmp)
            continue
        else:
            #print(mae_color,tmp_color,tmp,i)
            tmp_color += 1
            q.put(ab[tmp][i])
            if tmp_color == mae_color:
                tmp_color += 1
            check_color[ab[tmp][i]] = tmp_color
            ab_color[ab[tmp][i]][tmp] = tmp_color
            ab_color[tmp][ab[tmp][i]] = tmp_color
            check[tmp] = 1
            if color_num < tmp_color:
                color_num = tmp_color
            #color_num = max(color_num,tmp_color)
            #print(check,i)

print(color_num)
for i in range(len(li)):
    print(ab_color[li[i][0]][li[i][1]])

### FIXED CODE ###

import queue
n = int(input())


#ab = [[]*(n)]
ab = [[] for _ in range(n+1)]
#print(ab)

li = []

for i in range(n-1):
    a,b = map(int,input().split())
    ab[a].append([b,i])
    ab[b].append([a,i])
    #li.append([a,b])

#ab_color = [[None for _ in range(n+1)] for _ in range(n+1)]
ans = [0] * (n-1)

q = queue.Queue()
check = [0] * (n+1)
#check[1] == 1
check_color = [0] * (n+1)

q.put(1)
color_num = 1
#mae_color = 0

while not q.empty():
    tmp_color = 0
    tmp = q.get()
    #print(tmp)
    #tmp_color = mae_color
    mae_color = check_color[tmp]
    for i in range(len(ab[tmp])):
        if check[ab[tmp][i][0]] == 1:
            #print(i,tmp)
            continue
        else:
            #print(mae_color,tmp_color,tmp,i)
            tmp_color += 1
            q.put(ab[tmp][i][0])
            if tmp_color == mae_color:
                tmp_color += 1
            check_color[ab[tmp][i][0]] = tmp_color
            ans[ab[tmp][i][1]] = tmp_color
            #ab_color[ab[tmp][i]][tmp] = tmp_color
            #ab_color[tmp][ab[tmp][i]] = tmp_color
            check[tmp] = 1
            if color_num < tmp_color:
                color_num = tmp_color
            #color_num = max(color_num,tmp_color)
            #print(check,i)

print(color_num)
for i in range(len(ans)):
    print(ans[i])
### BUGGY CODE ###

mod = 1000000007

# nの素因数分解

def prime(n):
    d = []
    i = 2
    while n != 1:
        s = 0
        while n % i == 0:
            n /= i
            s += 1
        d.append(s)
        i += 1
    return d

# xのn乗を計算する
def mod_pow(x, n):
    if n == 1:
        return x
    elif n % 2 == 0:
        half_x = mod_pow(x, n // 2)
        return half_x * half_x % mod
    else:
        return x * mod_pow(x, n-1) % mod

fact = [0] * 100099
inv = [0] * 100099
fact[0] = 1
inv[0] = 1
for k in range(1, 100099):
    fact[k] = fact[k-1] * k % mod
    inv[k] = mod_pow(fact[k], mod-2)

def nCr(n, r):
    return fact[n] * inv[r] % mod * inv[n-r] % mod

def solve():
    N, M = map(int, input().split())
    p = prime(M)
    s = 1
    for i in p:
        s *= nCr(i + N - 1, N - 1)
        s %= mod
    print(s)

solve()

### FIXED CODE ###

from collections import Counter

mod = 1000000007

# nの素因数分解

def prime(n):
    d = Counter()
    i = 2
    while i*i <= n:
        while n%i == 0:
            n //= i
            d[i] += 1
        i += 1
    if n > 1:
        d[n] += 1
    return d

# xのn乗を計算する
def mod_pow(x, n):
    if n == 0:
        return 1
    elif n % 2 == 0:
        half_x = mod_pow(x, n // 2)
        return half_x * half_x % mod
    else:
        return x * mod_pow(x, n-1) % mod

fact = [1] * 100100
inv = [1] * 100100
for k in range(1, 100100):
    fact[k] = fact[k-1] * k % mod
    inv[k] = mod_pow(fact[k], mod-2)

def nCr(n, r):
    return fact[n] * inv[r] % mod * inv[n-r] % mod

def solve():
    N, M = map(int, input().split())
    p = prime(M)
    s = 1
    for i in p.values():
        s *= nCr(i + N - 1, N - 1)
        s %= mod
    print(s)

solve()
### BUGGY CODE ###

N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]
dp = [0]*(N+1)
dp[0] = 1
for i in range(1,N+1):
    if i in A:
        dp[i] = 0
    else:
        dp[i] = dp[i-1] + dp[i-2]
print(dp[N]%1000000007)

### FIXED CODE ###

N, M = map(int, input().split())
A = set([int(input()) for _ in range(M)])
dp = [0]*(N+1)
dp[0] = 1
for i in range(1,N+1):
    if i in A:
        dp[i] = 0
    else:
        dp[i] = (dp[i-1] + dp[i-2]) % (10**9+7)
print(dp[N])
### BUGGY CODE ###

import sys
input = sys.stdin.readline
N,M=map(int, input().split())
L=[ [] for _ in range(N)]

X=[]
for _ in range(M):
    a,b = input().split()
    a=int(a)
    b=int(b)
    L[a-1].append(b)
    X.append({a:b})
Y=[ (sorted(L[_])) for _ in range(N) ]
for i in range(M) :
    for k,v in X[i].items():
        print('%06d%06d' % (k,(Y[k-1].index(v)+1)))


### FIXED CODE ###

N,M = map(int,input().split())
L = []
for i in range(M):
    l = list(map(int,input().split()))+[i]
    L.append(l)
cnt = 0
tmp = []
M = sorted(L,key = lambda x: (x[0],x[1]))
for x in M:
    if tmp == x[0]:
        x.append(cnt+1)
        cnt += 1
    else:
        tmp = x[0]
        cnt = 0
        x.append(cnt)
M = sorted(L,key = lambda x:x[2])
#print(M)
for x in M:
    st = str(x[0]).zfill(6)
    st += str(x[3]+1).zfill(6)
    print(st)
### BUGGY CODE ###

N = int(input())
s = [sorted(input()) for i in range(N)]

s_int = []
for _s in s:
    v = list(map(lambda x: ord(x)-ord('a'), _s))
    v = sum([v[i]*26**i for i in range(len(v))])
    s_int.append(v)

cnt = [0 for _ in range(N)]
for i in range(N-1):
    cnt_i = 0
    for j in range(i+1, N):
        if (cnt[j] != 0):
            continue
        if (s_int[i] == s_int[j]):
            cnt_i += 1
            cnt[j] = cnt_i

print(sum(cnt))


### FIXED CODE ###

from collections import defaultdict
N = int(input())
s = [''.join(sorted(input())) for i in range(N)]
d = defaultdict(lambda: 0)

for _s in s:
    d[_s] += 1

print(sum(map(lambda x: x * (x-1) // 2, d.values())))
### BUGGY CODE ###

S = input()
N = len(S)
MOD = 10 ** 9 + 7

dp = [0, 0, 0, 0]
dp[0] = 1

for s in S:
    factor = 3 if s == '?' else 1
    for j, c in zip([2, 1, 0], 'CBA'):
        dp[j + 1] *= factor
        if s == c or s == '?':
            dp[j + 1] += dp[j]
    if s == '?':
        dp[0] *= 3

ans = dp[-1] % MOD

print(ans)

### FIXED CODE ###

S = input()
N = len(S)
MOD = 10 ** 9 + 7

dp = [0, 0, 0, 0]
dp[0] = 1

for s in S:
    factor = 3 if s == '?' else 1
    for j, c in zip([2, 1, 0], 'CBA'):
        dp[j + 1] = dp[j + 1] * factor % MOD
        if s == c or s == '?':
            dp[j + 1] += dp[j]
    if s == '?':
        dp[0] = (dp[0] * 3) % MOD

ans = dp[-1] % MOD

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

# ABC132 E
from collections import deque

f=lambda:map(int,input().split())
N,M=f()
G=[[] for _ in [0]*(N+1)]
for _ in [0]*M:
    a,b=f()
    G[a].append(b)
S,T=f()
    
def check(i):
    tmpF=[0]*(N+1)
    res=[(i,[i])]
    for i in range(3):
        tmpres=[]
        for r,par in res:
            for node in G[r]:
                tmpres.append((node,r))
        res=tmpres[:]
    return list(set([i for i,j in res]))

KKP=[[]]+[check(i+1) for i in range(N)]

F=[-1]*(N+1)
F[0]=-1
q=deque()
q.append((S,0))
while q:
    node,par=q.popleft()
    if F[node]>=0:
        continue
    F[node]=F[par]+1
    for nnode in KKP[node]:
        if F[nnode]>=0:
            continue
        q.append((nnode,node))
    if F[T]>=0:
        break
print(F[T])

### FIXED CODE ###

# ABC132 E
from collections import deque

f=lambda:map(int,input().split())
N,M=f()
G=[[] for _ in [0]*(N+1)]

for _ in [0]*M:
    a,b=f()
    G[a].append(b)
S,T=f()
S=(S,0)
T=(T,0)

q=deque()
q.append(S)
F=set()
res=-1
while q:
    node,r=q.popleft()
    if (node,r%3) in F:
        continue
    if (node,r%3) == T:
        res=r//3
        break
    F.add((node,r%3))
    for next_node in G[node]:
        if (next_node,(r+1)%3) in F:
            continue
        q.append((next_node,r+1))
print(res)
### BUGGY CODE ###

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

dic = {}

for a in A:
    if a in dic.keys():
        dic[a] += 1
    else: dic[a] = 1

flag = True
ini = N
if N % 2 == 1:
    if 0 in A:
        if dic[0] == 1:
            ini = 2
        else:
            flag = False
    else:
        flag = False
else:
    ini = 1

for i in range(ini,N,2):
    if not flag: break
    if i in A:
        if dic[i] != 2:
            flag = False
    else: flag = False

if flag:
    print(2**(N//2)%(10**9+7))
else:
    print(0)

### FIXED CODE ###

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

# N が奇数なら、Aはすべて偶数であり、かつ0を除いてすべて1ペア、かつ0が1つあるはず
# N が偶数なら、Aはすべて奇数であり、かつすべて1ペア
# 上記を確認するための辞書
dic = {}

for a in A:
    if a in dic.keys():
        dic[a] += 1
    else: dic[a] = 1

flag = True
ini = N
if N % 2 == 1:
    if 0 in A:
        if dic[0] == 1:
            ini = 2
        else:
            flag = False
    else:
        flag = False
else:
    ini = 1

for i in range(ini,N,2):
    if not flag: break
    if i in dic:
        if dic[i] != 2:
            flag = False
    else: flag = False

if flag:
    print(2**(N//2)%(10**9+7))
else:
    print(0)
### BUGGY CODE ###

import sys
from bisect import bisect as br, bisect_left as bl
readline = sys.stdin.readline

N = int(readline())
A = list(map(int, readline().split()))
B = list(map(int, readline().split()))
A.sort()
B.sort()
cnta = [0]*30
cntb = [0]*30
for idx in range(N):
    a, b = A[idx], B[idx]
    for i in range(30):
        if (1<<i) & a:
            cnta[i] += 1
        if (1<<i) & b:
            cntb[i] += 1

carry = [0]*31
bwa = [0]*N
bwb = [0]*N
for i in range(30):
    for idx in range(N):
        if (1<<i) & A[idx]:
            bwa[idx] |= 1<<i
        if (1<<i) & B[idx]:
            bwb[idx] |= 1<<i
    bwbc = sorted(bwb)
    m = (1<<(i+1))-1
    for idx in range(N):
        a = bwa[idx]
        carry[i+1] += N - bl(bwbc, m+1 if a == 0 else m&(-a))
        
ans = 0
for i in range(30):
    ca = cnta[i]
    cb = cntb[i]
    if (carry[i] + ca*(N-cb) + (N-ca)*cb) % 2 == 1:
        ans |= 1<<i
print(ans)

### FIXED CODE ###

import sys
readline = sys.stdin.readline

N = int(readline())
A = list(map(int, readline().split()))
B = list(map(int, readline().split()))
A.sort()
B.sort()
cnta = [0]*29
cntb = [0]*29
for idx in range(N):
    a, b = A[idx], B[idx]
    for i in range(29):
        if (1<<i) & a:
            cnta[i] = 1 - cnta[i]
        if (1<<i) & b:
            cntb[i] = 1 - cntb[i]

carry = [0]*30
bwa = [0]*N
bwb = [0]*N
for i in range(29):
    m = (1<<(i+1))-1
    bwbc = sorted([b&m for b in B])
    bwac = sorted([m+1 if a&m == 0 else m&(-(a&m)) for a in A])
    r = N
    for idx in range(N-1, -1, -1):
        a = bwac[idx]
        while r and bwbc[r-1] >= a:
            r -= 1
        carry[i+1] += N - r
        
ans = 0
for i in range(29):
    if (carry[i] + (cnta[i]+cntb[i])*N) % 2 == 1:
        ans |= 1<<i
print(ans)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

S = input()

for i in range(len(S)//2+1):
    S = S.replace('ST', '', 1)

print(len(S))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

S = input()
'''
f_cnt = b_cnt = 0
for m in S:
    if m != 'T':
        break
    f_cnt += 1

for m in S[::-1]:
    if m != 'S':
        break
    b_cnt += 1
print(max(f_cnt, b_cnt) * 2)
'''
s_cnt = 0
for m in S:
    if m == 'S':
        s_cnt += 1
    elif m == 'T' and s_cnt > 0:
        s_cnt -= 1

print(2*s_cnt)
### BUGGY CODE ###

l,r=map(int,input().split())
ans=2019
for i in range (l,r+1):
    for j in range(i+1,r+1):
       ans=min(ans,(i*j)%2019)
print(ans)

### FIXED CODE ###

L,R=map(int,input().split())
if R-L>=2019:
    minimum=0
else:
    left,right=L%2019,R%2019
    minimum=2018**2
    for i in range(left,right+1):
        for j in range(i+1,right+1):
            minimum=min(minimum,i*j%2019)
print(minimum)
### BUGGY CODE ###

N = int(input())
S =  input()
dp = [0] * N
min_selct = N//2
max_length = 0
for i in range(N):
    for j in range(N -i): 
        if S[i+j+1:N].find(S[i:i+j+1]) >= 0:
            max_length = max(max_length,j+1)
print(max_length)

### FIXED CODE ###

n = int(input())
S = input()
N = [0]*n
j = 0
 
for i in range(n):
  while S[i:j] in S[j:n]:
    N[i] = j-i
    j += 1
    
print(max(N))
### BUGGY CODE ###

K = int(input())
def gcd(a, b):
    c = 1
    for i in range(1, min([a+1, b+1])):
        if a%i==0 and b%i==0:
            c = i
    return c

count = 0
temp = list()
for n in range(1, K+1):
    for m in range(1, K+1):
        temp.append(gcd(n, m))
for l in range(1, K+1):
    for j in range(len(temp)):
        p = gcd(l, temp[j])
        count += p
print(count)

### FIXED CODE ###

K = int(input())
def gcd(a, b):
    if a < b:
        a, b = b, a
    while b != 0:
        r = a%b
        a = b
        b = r
    return a
count = 0
temp = list()
for n in range(1, K+1):
    for m in range(1, n):
        temp.append(gcd(n, m))
for l in range(1, K+1):
    for j in range(len(temp)):
        p = gcd(l, temp[j])
        count += 2 * p
    for k in range(1, K+1):
        q = gcd(l, k)
        count += q
print(count)
### BUGGY CODE ###

n = int(input())
c = 0
a = [i for i in range(n+1) if i%10 != 0]
for i in a:
    for j in a:
        if str(i)[0] == str(j)[-1] and str(j)[0] == str(i)[-1]:
            c += 1
print(c)

### FIXED CODE ###

n = int(input())
tbl=[[0 for j in range(10)] for i in range(10)]
for i in range(1,n+1):
    s= str(i)
    h=int(s[0])
    b=int(s[-1])
    tbl[h][b]+=1
ans = 0
for i in range(10):
    for j in range(10):
        ans+=tbl[i][j]*tbl[j][i]
print(ans)
### BUGGY CODE ###

import fractions as fr

from sys import stdin


def main():
    k = int(stdin.readline())

    g = [[[0 for _ in range(k)] for _ in range(k)] for _ in range(k)]

    for a in range(1, k + 1):
        for b in range(a, k + 1):
            g[a - 1][b - 1][0] = fr.gcd(a, b)
            for c in range(b, k + 1):
                g[a - 1][b - 1][c - 1] = fr.gcd(g[a - 1][b - 1][0], c)

    ans = 0

    for a in range(k):
        for b in range(k):
            for c in range(k):
                abc = sorted([a, b, c])
                ans += g[abc[0]][abc[1]][abc[2]]

    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

from math import factorial

from sys import stdin


def gcd(x, y):
    if x % y == 0:
        return y
    return gcd(y, x % y)


def main():
    k = int(stdin.readline())

    ans = 0

    for a in range(1, k + 1):
        for b in range(a, k + 1):
            d = gcd(a, b)
            for c in range(b, k + 1):
                e = gcd(d, c)
                ans += e * factorial(3) // factorial(3 - len(set([a, b, c])) + 1)

    print(ans)


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


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

x = {a:A.count(a) for a in set(A)}

for _ in range(Q):
    B, C = map(int, input().split())
    x[C] = x.get(C, 0) + x.get(B, 0)
    x[B] = 0
    print(sum(k * v for k, v in x.items()))

### FIXED CODE ###

import collections

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

x = dict(collections.Counter(A))
ans = sum(k * v for k, v in x.items())
for _ in range(Q):
    B, C = map(int, input().split())
    b = x.get(B, 0)
    c = x.get(C, 0)

    ans -= b * B
    ans += b * C

    x[C] = c + b
    x[B] = 0

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

n,k = map(int, raw_input().split(' '))
seen = {}

while(n not in seen):
	seen[n] = abs(n - k)
	n = abs(n - k)

print min(seen.values())

### FIXED CODE ###

n,k = map(int, raw_input().split(' '))
seen = {}

while(n not in seen):
	seen[n] = abs(n - k)
	if n == k:
		break
	elif n > k:
		if n - k < k:
			n = abs(n-k)
		else:
			n %= k
			n += k
		
	elif n < k:
		n = abs(n - k)
print min(seen.values())
### BUGGY CODE ###

import copy

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

for i in range(n):
    memo = copy.deepcopy(x)
    memo.pop(i)
    memo.sort()
    print(memo[(n - 1) // 2])

### FIXED CODE ###

n = int(input())
x = list(map(int, input().split()))
xs = sorted(x)
for i in range(n):
    if x[i] <= xs[n // 2 - 1]:
        res = xs[n // 2]
    else:
        res = xs[n // 2 - 1]
    print(res)
### BUGGY CODE ###

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

for i in range(k,n):
    thescore=a[i]
    lastsemester=a[i-1]
    for j in range(1,k):
        thescore*=a[i-j]
        lastsemester*=a[i-1-j]
    if thescore>lastsemester:
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

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

for i in range(k,n):
    if a[i]>a[i-k]:
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###


N=int(input())
input = input()
split = input.split()
data=[]
for i in range(N):
    data.append(int(split[i]))

sum_1=1

for i in data:
    sum_1=sum_1*i

if sum_1>1000000000000000000:
    print("-1")
else:
    print(sum_1)

### FIXED CODE ###

import sys

input = sys.stdin.readline

N = int(input())
x = sorted(list(map(int, input().split())))
t = 1

for num in x:
    t = t * num
    if t > 10 ** 18:
        print(-1)
        sys.exit()

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