Harryxun/stf_run huggingface dataset:
N = int(input())
A = list(map(int,input().split()))
ans = 0
process = []

def cumsum(reverse=False):
    global A,ans,process
    if reverse == False:
        for i in range(len(A)-1):
            A[i+1] += A[i]
            ans += 1
            process.append([i+1,i+2])
    else:
        for i in range(reversed(len(A)-1)):
            A[i-1] += A[i]
            ans += 1
            process.append([i,i+1])

def addmax():
    global A,ans,process
    ind = A.index(max(A))
    m = max(A)
    for i in range(N):
        A[i] += m
        ans += 1
        process.append([ind+1,i+1])

def addmin():
    global A,ans,process
    ind = A.index(min(A))
    m = min(A)
    for i in range(N):
        A[i] += m
        ans += 1
        process.append([ind+1,i+1])

def main():
    global A,ans,process
    if max(A) <= 0:##すべての要素が0以下の場合
        cumsum(reverse=True)
    elif min(A) >= 0:##すべての要素が0以上の場合
        cumsum()
    else:##正、負が両方ある場合
        if -1*min(A) < max(A):##最大値を足すほうが早い
            addmax()
            cumsum()
        else:##最小値を引くほうが畑井
            addmin()
            cumsum()
    ##出力
    print(ans)
    for i in range(ans):
        print(*process[i])

if __name__ == "__main__":
    main()

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
ans = 0
process = []

def cumsum(reverse=False):
    global A,ans,process
    if reverse == False:
        for i in range(len(A)-1):
            A[i+1] += A[i]
            ans += 1
            process.append([i+1,i+2])
    else:
        for i in reversed(range(len(A)-1)):
            A[i-1] += A[i]
            ans += 1
            process.append([i+2,i+1])

def addmax():
    global A,ans,process
    ind = A.index(max(A))
    m = max(A)
    for i in range(N):
        A[i] += m
        ans += 1
        process.append([ind+1,i+1])

def addmin():
    global A,ans,process
    ind = A.index(min(A))
    m = min(A)
    for i in range(N):
        A[i] += m
        ans += 1
        process.append([ind+1,i+1])

def main():
    global A,ans,process
    if max(A) <= 0:##すべての要素が0以下の場合
        cumsum(reverse=True)
    elif min(A) >= 0:##すべての要素が0以上の場合
        cumsum()
    else:##正、負が両方ある場合
        if -1*min(A) < max(A):##最大値を足すほうが早い
            addmax()
            cumsum()
        else:##最小値を引くほうが畑井
            addmin()
            cumsum(reverse=True)
    ##出力
    print(ans)
    for i in range(ans):
        print(*process[i])

if __name__ == "__main__":
    main()
# tenka1-2017-beginnerB - Different Distribution
def main():
    N, *AB = map(int, open(0).read().split())
    A = [sum(i, j) for i, j in zip(*[iter(AB)] * 2)]
    ans == max(A)
    print(ans)


if __name__ == "__main__":
    main()

### FIXED CODE ###

# tenka1-2017-beginnerB - Different Distribution
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    A = sorted(tuple(map(int, input().rstrip().split())) for _ in range(n))
    print(A[-1][0] + A[-1][1])


if __name__ == "__main__":
    main()
S=input()
K=input()
if len(S)<=K:
    print(S)
else:
    print(S[:K]+"...")

### FIXED CODE ###

K=int(input())
S=input()
if len(S)<=K:
    print(S)
else:
    print(S[:K]+"...")
import sys
Q = int(input())
mod = 1000003
frac = [1]*1000003
for i in range(2,1000003):
    frac[i] = i * frac[i-1]%mod
for _ in range(Q):
    x, d, n = map(int, sys.stdin.readline().split())
    p = pow(d, mod-2, mod)*x % mod
    print(frac[p+n-1]*pow(frac[p-1], mod-2, mod)*pow(d, n, mod)%mod)


### FIXED CODE ###

import sys
Q = int(input())
mod = 1000003
frac = [1]*1000003
for i in range(2,1000003):
    frac[i] = i * frac[i-1]%mod
for _ in range(Q):
    x, d, n = map(int, sys.stdin.readline().split())
    p = pow(d, mod-2, mod)*x % mod
    if d == 0:
        print(pow(x, n, mod))
        continue
    elif x == 0:
        print(0)
        continue
    elif p == 0:
        print(0)
        continue
    elif p + n - 1 >= mod:
        print(0)
        continue
    
    print(frac[p+n-1]*pow(frac[p-1], mod-2, mod)*pow(d, n, mod)%mod)
print(input() ** 3)


### FIXED CODE ###

print(int(input()) ** 3)
A = input()
if A == RRR
	print("3")
elif A == SSS
	print("0")
elif A == RRS
	print("2")
elif A == SRR
	print("2")
else 
	print("1")


### FIXED CODE ###

S = input()
if S.count("R") == 3:
	print("3")
elif S.count("R") == 0:
	print("0")
elif S.count("RR") == 1:
  	print("2")
else:
	print("1")
(A, B, C) = map(input().split(), int)

if A + B + C >= 22:
  print("bust")
else:
  print("win")

### FIXED CODE ###

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

if A + B + C >= 22:
  print("bust")
else:
  print("win")
import sys
input = sys.stdin.readline

def main():
    x = int(input())
    for i in range(-1000, 1000):
        for j in range(-1000, 1000):
            if x == i**5 - j**5:
                print(i, j)
                break
        else:
            continue
        break

if __name__ == '__main__':
    main()

### FIXED CODE ###

n, m = map(int, input().split())
h = list(map(int, input().split()))
l_n = [0] * n
for i in range(m):
    a, b = map(int, input().split())
    if h[a-1] == h[b-1]:
        l_n[a-1] = 1
        l_n[b-1] = 1
    elif h[a-1] > h[b-1]:
        l_n[b-1] = 1
    elif h[a-1] < h[b-1]:
        l_n[a-1] = 1
print(l_n.count(0))
n,l=map(int,input().split())
m=map(str,input())
A=m[l-1]
for i in range(5):
    if m[i]==A:
        continue
        if m[i]!=A:
            m[i]='*'
print(m)

### FIXED CODE ###

n,s,k=int(input()),input(),int(input()) #入力を順番に一気に定義する
A=s[k-1]
for i in range(n):
    if s[i]!=A:
        s=s.replace(s[i],'*')
print(s)
n = int(input())
a = map(int,input().split())

c = 0
while flag:
    flag = False
    for j in range(n-1,1,-1):
        if(a[j] < a[j-1]):
            a[j],a[j-1] = a[j-1],a[j]
            flag = 1
            c += 1
print(*a)
print(c)


### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
flag = True
c = 0
while flag:
    flag = False
    for j in range(n-1,0,-1):
        if(a[j] < a[j-1]):
            a[j],a[j-1] = a[j-1],a[j]
            flag = True
            c += 1
print(*a)
print(c)
n,x,t = input().split()

n = n//x
print(n*t)

### FIXED CODE ###

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

n = math.ceil(n/x)
print(n*t)
def solve():
    n = int(input())
    a = list(map(int, input().split()))

    one = n*(n+1)/2

    if sum(a) % one != 0:
        print("NO")
    else:
        nop = sum(a) / one

    d = [0 for i in range(n)]
    for i in range(n):
        d[i] = a[(i+1)%n] - a[i]
        d[i] = d[i] - nop

    count = 0

    for i in range(n):
        if d[i] != 0:
            if d[i] % n != 0:
                print("NO")
                return
            count = count + (-1*d[i]) / n
            d[i] = 0
            if count > nop:
                print("NO")
                return

    if sum(d) == 0 and count == nop:
        print("YES")
    else:
        print("NO")

solve()

### FIXED CODE ###


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

    one = n*(n+1)/2

    if sum(a) % one != 0:
        print("NO")
        return
    else:
        nop = sum(a) / one

    d = [0 for i in range(n)]
    for i in range(n):
        d[i] = a[(i+1)%n] - a[i]
        d[i] = d[i] - nop

    count = 0

    for i in range(n):
        if d[i] != 0:
            if d[i] % n != 0 or d[i] > 0:
                print("NO")
                return
            count = count + (-1*d[i]) / n
            d[i] = 0
            if count > nop:
                print("NO")
                return

    if sum(d) == 0 and count == nop:
        print("YES")
    else:
        print("NO")

solve()
def warshall_floyd(G):
    import copy
    ret = copy.deepcopy(G)
    for k in range(N):
        for i in range(N):
            for j in range(N):
                ret[i][j] = min(ret[i][j], ret[i][k] + ret[k][j])
    return ret


N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]

if A == warshall_floyd(A):
    ans = 0
    for i in range(1, N):
        for j in range(0, i):
            if min([A[i][k] + A[k][j] - A[i][j] for k in range(N) if k != i and k != j]) > 0:
                ans += A[i][j]
    print(ans)
else:
    print(-1)


### FIXED CODE ###

def warshall_floyd(G):
    import copy
    ret = copy.deepcopy(G)
    for k in range(N):
        for i in range(N):
            for j in range(N):
                ret[i][j] = min(ret[i][j], ret[i][k] + ret[k][j])
    return ret


N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]

if A == warshall_floyd(A):
    ans = 0
    for i in range(1, N):
        for j in range(0, i):
            if min([A[i][k] + A[k][j] - A[i][j] for k in range(N) if k != i and k != j] + [1]) > 0:
                ans += A[i][j]
    print(ans)
else:
    print(-1)
from sys import stdin
H,W = [int(x) for x in stdin.readline().rstrip().split()]
data = ["#"*(W+2)]
for _ in range(H):
    data.append("#" + input() + "#")
deta.append("#"*(W+2))
for j in data:
    print(j)

### FIXED CODE ###

from sys import stdin
H,W = [int(x) for x in stdin.readline().rstrip().split()]
data = ["#"*(W+2)]
for _ in range(H):
    data.append("#" + input() + "#")
data.append("#"*(W+2))
for j in data:
    print(j)
import numpy as np
import copy
n,k,c = map(int,input().split())
dp = [0]*(n+c+2)
s = input()
idx = []
for i in range(n):
    if s[i]=='o':
        idx.append(i+1)
for i in idx:
    dp[i] += 1
    dp[i+c+1] -= 1
dp = np.cumsum(dp).tolist()

for i in idx:
    tmp = copy.deepcopy(dp)
    for j in range(i, i+c+1):
        tmp[j] -= 1

    cnt = 0
    flg = False
    for j in range(len(tmp[1:-1])):
        if tmp[1+j]!=0 and flg==False:
            flg = True
            cnt += 1
        if tmp[1+j]!=0 and flg:
            continue
        if tmp[1+j]==0:
            flg = False
    if cnt<k:
        print(i)

### FIXED CODE ###

import bisect
n,k,c = map(int,input().split())
s = input()

lst = []
for i in range(n):
    if s[i]=='o':
        lst.append(i+1)

x,y = [],[]
for i in range(len(lst)):
    if i==0:
        x.append(lst[i])
    else:
        if lst[i]-x[-1]>c:
            x.append(lst[i])
    if len(x)==k:
        break

for i in range(len(lst))[::-1]:
    if i==len(lst)-1:
        y.append(lst[i])
    else:
        if y[-1]-lst[i]>c:
            y.append(lst[i])
    if len(y)==k:
        break

x.sort()
y.sort()

ans = []
for i in range(k):
    if x[i]==y[i]:
        ans.append(x[i])
for a in ans:
    print(a)
X,A = input()

if X < A:
    print('0')
else:
    print('10')

### FIXED CODE ###

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

if X < A:
    print('0')
else:
    print('10')
II.c=-1

N,M = [ int(it) for it in input().split() ]
li = [ [ int(it) for it in input().split() ] for i in range(M) ]

up = [ set([]) for i in range(N)]
dw = [ set([]) for i in range(N)]

for l,r,d in li:
  dw[l-1].add(r-1)
  up[r-1].add(l-1)

S = []
for n in range(N):
  if ( len(up[n])==0 ):
    S.append(n)
L = []
for i in range(N+M):

  if ( len(S)==0 ):
    break
  n = S.pop()
  L.append(n)
  for r in dw[n]:
    up[r].discard(n)
    if ( len(up[r]) == 0 ):
      S.append(r)
  dw[n]=set()

BREAK=False
if (sum([len(s) for s in up])>0):
    BREAK=True

dwl = [ set([]) for i in range(N)]
for l,r,d in li:
  dwl[l-1].add((r-1,d))

dis = [-1]*N

for n in L:
  if (BREAK):
    break
  if (dis[n]==-1):
    dis[n]=0
  for r,d in dwl[n]:
    if (dis[r]==-1):
        dis[r]=dis[n]+d
    else:
        if not (dis[r]==dis[n]+d):
            BREAK=True
            break
if (BREAK):
    print ("No")
else:
    print ("Yes")


        

### FIXED CODE ###

N,M = [ int(it) for it in input().split() ]
li = [ [ int(it) for it in input().split() ] for i in range(M) ]

up = [ set([]) for i in range(N)]
dw = [ set([]) for i in range(N)]

for l,r,d in li:
  dw[l-1].add(r-1)
  up[r-1].add(l-1)

S = []
for n in range(N):
  if ( len(up[n])==0 ):
    S.append(n)
L = []
for i in range(N+M):

  if ( len(S)==0 ):
    break
  n = S.pop()
  L.append(n)
  for r in dw[n]:
    up[r].discard(n)
    if ( len(up[r]) == 0 ):
      S.append(r)
  dw[n]=set()

BREAK=False
if (sum([len(s) for s in up])>0):
    BREAK=True

dwl = [ set([]) for i in range(N)]
for l,r,d in li:
  dwl[l-1].add((r-1,d))

dis = [-1]*N

for n in L:
  if (BREAK):
    break
  if (dis[n]==-1):
    dis[n]=0
  for r,d in dwl[n]:
    if (dis[r]==-1):
        dis[r]=dis[n]+d
    else:
        if not (dis[r]==dis[n]+d):
            BREAK=True
            break
if (BREAK):
    print ("No")
else:
    print ("Yes")
N,M = map(int,input().split())
dic = {}
for _ in range(N):
  a, b = map(int,input().split())
  if a in dic:
    dic[a] += b
  else:
    dic[a] = b
List = sorted(dic)[::-1]
ans = 0
i = 1
while M > 0:
  M -= dic[i]
  ans = i
  i += 1
print(ans)


### FIXED CODE ###

N,M = map(int,input().split())
dic = {}
for _ in range(N):
  a, b = map(int,input().split())
  if a in dic:
    dic[a] += b
  else:
    dic[a] = b
List = sorted(dic)
ans = 0
i = 0
while M > 0:
  M -= dic[List[i]]
  ans = List[i]
  i += 1
print(ans)
l = input()
m = input()
z = l.split(" ")
M = int(l[1])
N = int(l[0])
C = (1/(4*M))*N
F = m.split(" ")
X = []
for item in f:
	votes = int(item)
	X.append(votes)
	X.sort()
for i in range(M):
	if X[i]<C:
		print("No")
		return
print("Yes")

### FIXED CODE ###

l = input()
m = input()
z = l.split(' ')
M = int(z[1])
N = int(z[0])
F = m.split(' ')
X = []
 
for item in F:
  votes = int(item)
  X.append(votes)

S = sum(X)
C = (S/(4*M))
X.sort(reverse=True)
if X[M-1]<C:
  print("No")
else:
  print("Yes")
a=input()
if a=="ABC":
  ptint("ARC")
else:
  print("ABC")

### FIXED CODE ###

a=input()
if a=="ABC":
  print("ARC")
else:
  print("ABC")
import sys
sys.setrecursionlimit(100000)

def search(i,x,con,val):
    if con[i] :
        for j in con[i]:
            search(j,x,con,val)
    val[i]+=x

def tree(i,con):
    if not con[i]: pass
    else :
        for j in con[i]:
            con[j].remove(i)
            tree(j,con)

def main():
    n,q=map(int,input().split())
    con=[[] for _ in range(n)]
    val=[0]*n
    for _ in range(n-1):
        a,b=map(int,input().split())
        con[a-1].append(b-1)
        con[b-1].append(a-1)

    tree(0,con)

    for _ in range(q):
        p,x=map(int,input().split())
        search(p-1,x,con,val)

    print(" ".join(map(str,val)))

main()

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

def val_add(i,con,val):
    if con[i] :
        for j in con[i]:
            val[j]+=val[i]
            val_add(j,con,val)

def tree(i,con):
    if not con[i]: pass
    else :
        for j in con[i]:
            con[j].remove(i)
            tree(j,con)

def main():
    n,q=map(int,input().split())
    con=[[] for _ in range(n)]
    val=[0]*n
    for _ in range(n-1):
        a,b=map(int,input().split())
        con[a-1].append(b-1)
        con[b-1].append(a-1)

    tree(0,con)

    for _ in range(q):
        p,x=map(int,input().split())
        val[p-1]+=x

    val_add(0,con,val)


    print(" ".join(map(str,val)))

main()
s = input()
for i in range(3):
  if s[i] =="1":
    s[i] = "9"
  else:
    s[i] = "1"
print(s)

### FIXED CODE ###

s = input()
s =s.replace("1","a").replace("9","1").replace("a","9")
print(s)
def main():
    N = int(input())
    X = list(map(int, input().split(" ")))

    nums = list(set(X))
    lis = [-1]*200001

    for x in X:
        lis[x] += 1

    for x in X:
        if lis[x] < 1:
            ind = nums.index(x)
            edited = nums[:ind] + nums[ind+1:]
            
            print(edited[len(edited)//2])
        else:
            print(nums[len(nums)//2])



if __name__ == '__main__':
    main()


### FIXED CODE ###



def main():
    N = int(input())
    X = list(map(int, input().split(" ")))

    nums = sorted(X)
    center = len(nums)//2

    dic = {}
    for i,x in enumerate(nums):
        if x not in dic:
            dic[x] = i

    if len(nums)%2 == 0:
        is_even = True
    else:
        is_even = False

    for x in X:
        i = dic[x]
        if is_even:
            if i < center:
                print(nums[center])
            else:
                print(nums[center-1])
        else:
            print(nums[center+1])


if __name__ == '__main__':
    main()
A, B = map(int, input().split())
C = -(-A//0.08)
D = -(-(A+1)//0.08)
for i in range(C,D):
    if i//10 == B:
        break
        print(i)
else:
    print(-1)

### FIXED CODE ###

A, B = map(int, input().split())
C = int(-(-A//0.08))
D = int(-(-(A+1)//0.08))
for i in range(C,D):
    if i//10 == B:
      print(i)
      break
else:
    print(-1)
I,O,T,J,L,S,Z = map(int,input().split())
if I==1 and J==1 and L==1:                                                     
    print(3) 
elif ((I-1)//2+(J-1)//2+(L-1)//2)*2+O==0 and (I//2+J//2+L//2)*2+O)==0:
    print(0)
else:
    print(max(((I-1)//2+(J-1)//2+(L-1)//2)*2+O+3,(I//2+J//2+L//2)*2+O))


### FIXED CODE ###

I,O,T,J,L,S,Z = map(int,input().split())
print(max(((I-1)//2+(J-1)//2+(L-1)//2)*2+O+3*(I>0)*(L>0)*(J>0),(I//2+J//2+L//2)*2+O))
import sys
from collections import defaultdict
from itertools import combinations

def n_cmb(n, r):
    from math import factorial
    return factorial(n) / factorial(r) / factorial(n - r)

f = sys.stdin
n = int(f.readline())
s = f.readline()[:-1]

duplicates = defaultdict(list)
for idx, v in enumerate(s):
    duplicates[v].append(idx)
print(duplicates)
n_duplicates = 0
for key in duplicates:
    # import pdb
    # pdb.set_trace()
    idxs = duplicates[key]
    n_idxs = len(idxs)
    if n_idxs > 3:
        n_duplicates += n_cmb(n_idxs - 3, 1)
    if n_idxs == 1:
        continue
    for i in range(n_idxs-1):
        for j in range(i+1, n_idxs):
            m = idxs[i] + n - idxs[j] - 1
            if m < 2:
                continue
            n_duplicates += n_cmb(m, 2)
print(n_cmb(n, 3))
print(n_duplicates)
result = n_cmb(n, 3) - n_duplicates

print(result)

### FIXED CODE ###

import sys

def is_password(s, p):
    check = s.find(p[0])
    idx = check + 1
    if check == -1:
        return False
    check = s[idx:].find(p[1])
    if check == -1:
        return False
    idx = idx + check + 1
    check = s[idx:].find(p[2])
    if check == -1:
        return False
    return True

f = sys.stdin
n = int(f.readline())
s = f.readline()[:-1]

count = 0
for l1 in range(10):
    for l2 in range(10):
        for l3 in range(10):
            p = str(l1) + str(l2) + str(l3)
            if is_password(s, p):
                count += 1

print(count)
input(a)
if(a%2==1):
	i=(a+1)/2
	j=(a-1)/2
else:
	i=a/2
	j=a/2
print(i+j)

### FIXED CODE ###

a=int(input())
if a%2==0:
  ans=int((a/2)**2)
else:
  ans=int(((a-1)/2)*((a+1)/2))
print(ans)
import sys
import math

input = sys.stdin.readline
N=int(input().rstrip())
h=list(map(int,input().rstrip().split()))

dp=[0]*N
for i in range(N):
    dp[i]=math.inf
dp[0]=0

for i in range(1,N,1):
    dp[i]=min(dp[i],dp[i-1]+abs(h[i]-h[i-1]))
    if(i>1):        
        dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]))
print(dp[N-1])
          


### FIXED CODE ###

import sys
input = sys.stdin.readline
N=int(input().rstrip())
h=list(map(int,input().rstrip().split()))

dp=[0]*N
for i in range(N):
    dp[i]=1000000000000
dp[0]=0

for i in range(1,N,1):
    dp[i]=min(dp[i],dp[i-1]+abs(h[i]-h[i-1]))
    if(i>1):        
        dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]))

print(dp[N-1])
from scipy.special import comb

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

for i in range(1,k+1):
    print((comb(n-k+1, i, exact=True) * comb(k-1, i-1, exact=True))%(1000000007))


### FIXED CODE ###

def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

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



for i in range(1,k+1):
    if (n-k+1) >= i:
        print((comb(n-k+1, i) * comb(k-1, i-1))%(1000000007))
    else:
        print(0)
n = int(input())
sl = list(input())[:-1]

q = int(input())
kl = list(map(int,input().split()))

for k in kl:
    # i文字目までのdとmとdmの数
    d = 0
    m = 0
    dm = 0
    ans = 0
    for i in range(n):
        if i - k >= 0:
            if sl[i-k] == "D":
                d -= 1
                dm -= m
            if sl[i-k] == "M":
                m -= 1
        if sl[i] == "D":
            d += 1
        if sl[i] == "M":
            m += 1
            dm += d
        if sl[i] == "C":
            ans += dm

    print(ans)









### FIXED CODE ###

import sys
input = sys.stdin.readline

def main():
    N = int(input())
    S = input()
    Q = int(input())
    x = tuple(map(int,input().split()))
    for k in x:
        d,m,dm,dmc = 0,0,0,0
        for i in range(N):
            if S[i] == "D":
                d += 1
            elif S[i] == "M":
                m += 1
                dm += d
            elif S[i] == "C":
                dmc += dm
            if i >= k-1:
                if S[i-k+1] == "D":
                    dm -= m
                    d -= 1
                elif S[i-k+1] == "M":
                    m -= 1
        print(dmc)
    
if __name__ == "__main__":
    main()
c = { 
	'S' : [0 for _ in range(13)], ???H??? : [0 for _ in range(13)],
	'C' : [0 for _ in range(13)], ???D??? : [0 for _ in range(13)]
}

x = int(input())
for _ in range(x):
	(a, b) = input().split()
	b = int(b)
	c[a][b - 1] = b

for a in ('S', 'H', 'C', 'D'):
	for b in range(13):
		if c[a][b] == 0:
			print('{0:s} {1:d}'.format(a, b+1))

### FIXED CODE ###

c = { 
    'S' : [0 for _ in range(13)], 'H' : [0 for _ in range(13)],
    'C' : [0 for _ in range(13)], 'D' : [0 for _ in range(13)]
}
 
x = int(input())
for _ in range(x):
    (a, b) = input().split()
    b = int(b)
    c[a][b - 1] = b
 
for a in ('S', 'H', 'C', 'D'):
    for b in range(13):
        if c[a][b] == 0:
            print('{0:s} {1:d}'.format(a, b+1))
S = coffee
if S is coffee-like
    return("Yes")
    else
    print("No")
  
  


### FIXED CODE ###

def get_count(text):
    if text[2] == text[3] and text[4] == text[5]:
        return 'Yes'
    else:
        return 'No'
 
 
if __name__ == '__main__':
    string = input().strip()
 
    result = get_count(string)
    print(result)
import numpy as np

nums = []
for i in range(5):
	nums.append(int(input()))

remainders = [0,0,0,0,0]
for i in range(5):
	remainders[i] = nums[i] % 10

sortedRemainders = np.argsort(remainders)

for i in range(5):
	sortedNums[i] = nums[sortedRemainders[i]]

elapsedTime = 0
for i in range(4):
	if sortedRemainders[i] == 0:
		elapsedTime += sortedNums[i]
	else:
		elapsedTime += sortedNums[i] + 10 - sortedRemainders

elapsedTime += sortedNums[4]

print(elapsedTime)

### FIXED CODE ###

import numpy as np

nums = []
sortedNums = [0,0,0,0,0]
sortedRemainders = [0,0,0,0,0]
for i in range(5):
	nums.append(int(input()))

remainders = [0,0,0,0,0]
for i in range(5):
	if nums[i] % 10 == 0:
		remainders[i] = 10
	else:
		remainders[i] = nums[i] % 10

sortedRemaindersIndex = np.ndarray.tolist(np.argsort(remainders))

for i in range(5):
	sortedNums[i] = nums[sortedRemaindersIndex[i]]

elapsedTime = 0
for i in range(4):
	if sortedNums[i+1] % 10 == 0:
		elapsedTime += sortedNums[i+1]
	else:
		elapsedTime += sortedNums[i+1] + 10 - sortedNums[i+1] % 10

elapsedTime += sortedNums[0]

print(elapsedTime)
import numpy as np
N = int(input())
a = list(map(int,input().split()))

b = np.array(a)

ans = np.prod(b)

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

### FIXED CODE ###

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

if A.count(0) > 0:
  print(0)
else:
  ans = A[0]
  flag = 0
  for i in range(1,N):
    ans *= A[i]
    if ans > 10 ** 18:
      print(-1)
      flag += 1
      break
  if flag == 0:
    print(ans)