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

def rabin_karp(T, P, d):
    n = len(T)
    m = len(P)
    if n < m:
        return
    h = 1
    p = 0
    t0 = 0
    for _ in range(m - 1):
        h *= d
    for i in range(m):
        p = d * p + P[i]
        t0 = d * t0 + T[i]
    # print("h = ", h)
    # print("p = ", p)
    for s in range(n - m + 1):
        # print("t0 = ", t0)
        if p == t0:
            print(s)
        if s < n - m:
            # print("     ", t0 - T[s] * h)
            # print("     ",  d)
            # print("     ", T[s + m])
            t0 = d * (t0 - T[s] * h) + T[s + m]


d = 167
t = list(map(ord, input()))
p = list(map(ord, input()))

rabin_karp(t, p, d)


### FIXED CODE ###

def compute_prefix_function(p):
    m = len(p)
    pi = [0 for _ in range(m + 1)]
    pi[1] = 0
    k = 0
    for q in range(2, m + 1):
        while k > 0 and p[k] != p[q - 1]:
            k = pi[k]
        if p[k] == p[q - 1]:
            k += 1
        pi[q] = k
    return pi


def kmp_matcher(t, p):
    n = len(t)
    m = len(p)
    pi = compute_prefix_function(p)
    q = 0
    for i in range(1, n + 1):
        while q > 0 and p[q] != t[i - 1]:
            q = pi[q]
        if p[q] == t[i - 1]:
            q += 1
        if q == m:
            print(i - m)
            q = pi[q]


t = input()
p = input()
kmp_matcher(t, p)
### BUGGY CODE ###

from functools import reduce
import operator

NK = list(map(int, input().split(' ')))
N = NK[0]
K = NK[1]
A_list = list(map(int, input().split(' ')))
score_list = []

for g in range(K, N+1):
    score = reduce(operator.mul, A_list[g-K: g])
    score_list.append(score)

for i in range(len(score_list) - 1):
    if (score_list[i] < score_list[i+1]):
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

NK = list(map(int, input().split(' ')))
N = NK[0]
K = NK[1]
A = list(map(int, input().split(' ')))

for i in range(K, N):
    if (A[i-K] < A[i]):
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

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

# 入力された文字列
string = input()

# 最大処理数。100000以下なら文字列長。
max = min(len(string), 100000)

# 削除した文字数
del_count = 0

# 削除があった場合True
del_flg = True

# 削除文字がなくなるまでループする
while del_flg:
    del_flg = False

    # 
    for idx in range(max):
        # 照合対象の文字を切り出す
        target = string[idx : idx + 2]
        
        if target == "01" or target == "10":
            # 削除文字に一致した場合、元の文字列からそれを削除しカウントを進め、
            # 削除フラグを立てる
            string_head = string[:idx]
            string_tail = string[idx + 2:]
            string = string_head + string_tail
            del_count += 2
            del_flg = True

print(del_count)

### FIXED CODE ###

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

string = input()

red_count  = string.count('0')
blue_count = string.count('1')

print(min(red_count, blue_count) * 2)
### BUGGY CODE ###

def possibleCombos(num):
    return sum([i-1 for i in range(1,num+1)])


N = int(input())
A = [i for i in input().split()]
keys = {}
for i in A:
    if  i not in keys.keys():
        keys[i] = 1
        continue 
    keys[i] += 1
for i in A:
    combos = 0
    for k in keys.keys():
        num = keys[k]-1 if k == i else keys[k]
        combos += possibleCombos(num)
    print(combos)


### FIXED CODE ###

def possibleCombos(num):
    num2 = num - 1
    return (num2*num2 + num2)//2
N = int(input())
A = [int(i) for i in input().split()]
data = [0] * (N+1)
total = 0
for i in A:

    data[i] +=1

for i in data:
    total += possibleCombos(i)
for i in A:
    result = total - possibleCombos(data[i]) + possibleCombos(data[i]-1)
    print(result)
### BUGGY CODE ###

s = input()
q = int(input())

query = [input() for _ in range(q)]

right = ""
left = ""
for qu in query:
    if len(qu.split()) == 1:
        right, left = left, right
        s = s[::-1]
        continue
    num, f, c = qu.split()
    f = int(f)

    if f == 1:
        left += c
        
    else:
        right += c


print(left[::-1] + s + right)


### FIXED CODE ###

s = input()
q = int(input())

query = [input() for _ in range(q)]
count = 0
right = ""
left = ""
for qu in query:
    if len(qu.split()) == 1:
        count += 1
        right, left = left, right
        continue
    num, f, c = qu.split()
    f = int(f)

    if f == 1:
        left += c
        
    else:
        right += c
if count % 2 == 1:
  s = s[::-1]

print(left[::-1] + s + right)
### BUGGY CODE ###

from fractions import gcd

mod = 10 ** 9 + 7

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

lcm = 1
for s in A:
    lcm = s * lcm // gcd(lcm, s)

# ans = lcm * sum([pow(s, mod - 2, mod) for s in A]) % mod
ans = sum([lcm//s % mod for s in A]) % mod

print(int(ans % mod))


### FIXED CODE ###

from fractions import gcd

mod = 10 ** 9 + 7

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

lcm = 1
for s in A:
    lcm = s * lcm // gcd(lcm, s)

ans = lcm * sum([pow(s, mod - 2, mod) for s in A]) % mod

print(int(ans % mod))
### BUGGY CODE ###

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

hantei = True
cnt = 0
for i in range(N):
    temp = s.pop(0)
    for S in s:
        for k in range(len(temp)):
            if S.count(temp[k]) != temp.count(temp[k]):
                hantei = False
                break
        if hantei:
            cnt += 1
        else:
            hantei = True

print(cnt)


### FIXED CODE ###

N = int(input())
s = [list(input()) for _ in range(N)]
S = []
for i in range(N):
    temp = "".join(sorted(s[i]))
    S.append(temp)

D = {}
cnt = 0
for str in S:
    if str in D:
        cnt += D[str]
        D[str] += 1
    else:
        D[str] = 1

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

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

S = input()

for i in range(Q):
    l,r = map(int, input().split())
    Slr = S[l-1:r]
    print(Slr.count('AC'))


### FIXED CODE ###

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

S = input()

t = [0] * (N+1)

for i in range(N):
    t[i+1] = t[i] + (1 if S[i:i+2] == 'AC' else 0)

for i in range(Q):
    l,r = map(int, input().split())
    print(t[r-1] - t[l-1])
### BUGGY CODE ###

N, M = map(int,input().split(' '))
a = [int(input()) for i in range(M)]
ans = [0]*(N+1)
ans[0] = 1
for i in range(1,N+1):
  if i in a:
    ans[i] = 0
  else:
    ans[i] = (ans[i-1]+ans[i-2])%(10**9+7)
print(ans[N])

### FIXED CODE ###

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

from collections import Counter
n = int(input())
s = []
for i in range(n):
    s.append(Counter(list(input())))
ans = s.copy()
cnt_ans = 0
while len(s):
    remove_list = []
    cnt = 0
    for i in range(1, len(s)):
        if s[0] == s[i]:
            cnt += 1
            remove_list.append(s[i])
    cnt = int((cnt+1) * (cnt) / 2)
    cnt_ans += cnt
    remove_list.append(s[0])
    for lst in remove_list:
        s.remove(lst)
print(cnt_ans)

### FIXED CODE ###

n = int(input())
s = []
for i in range(n):
    s.append(sorted(list(input())))
cnt_ans = 0
s.sort()
cnt = 0
left = 0
right = 1
while right <= n-1:
    if s[left] == s[right]:
        right += 1
        cnt += 1
    else:
        left, right = right, right+1
        cnt_ans += ((cnt+1)*cnt//2)
        cnt = 0
    if right == n:
        cnt_ans += ((cnt+1)*cnt//2)
print(cnt_ans)
### BUGGY CODE ###

K, S = map(int,input().split())
ans = 0
for i in range(K+1):
  for j in range(K+1):
    for k in range(K+1):
      if int(i + j + k) == S: ans += 1
print(ans)

### FIXED CODE ###

K, S = map(int,input().split())
ans = 0
for x in range(K+1):
  for y in range(K+1):
    z = S - x - y
    if 0 <= z and z <= K: ans += 1
print(ans)
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
ans=10**10
cnt=0
for i in range(len(a)-1):
    cnt+=a[i]
    ans=min(ans,abs(cnt*2-sum(a)))
print(ans)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
ans=10**10
cnt=0
rest=sum(a)
for i in range(len(a)-1):
    cnt+=a[i]
    rest-=a[i]
    ans=min(ans,abs(rest-cnt))
print(ans)
### BUGGY CODE ###

# seishin.py
N = int(input())
MOD = 10**9 + 7

fact = [1]*(N+1)
rfact = [1]*(N+1)

for i in range(1, N+1):
    fact[i] = r = i*fact[i-1] % MOD
    rfact[i] = pow(r, MOD-2, MOD)

ans = 0
cnt = 0
for K in range(1, N):
    if not K >= N-K >= 1:
        continue
    res = fact[K]*fact[K-1]*rfact[2*K-N] % MOD
    ans += (res - cnt) * K % MOD
    cnt = res
print(ans % MOD)

### FIXED CODE ###

# seishin.py
N = int(input())
MOD = 10**9 + 7

fact = [1]*(N+1)
rfact = [1]*(N+1)

for i in range(1, N+1):
    fact[i] = r = i*fact[i-1] % MOD
    rfact[i] = pow(r, MOD-2, MOD)

ans = cnt = 0
for K in range((N+1)//2, N):
    res = fact[K]*fact[K-1]*rfact[2*K-N] % MOD
    ans += (res - cnt) * K % MOD
    cnt = res
    ans %= MOD
print(ans)
### BUGGY CODE ###

#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n=int(input())
L=list(map(int,input().split()))
A = L.count(1)
B = L.count(2)
C = L.count(3)
dp=[[[0] * (n+1) for i in range(n+1)] for i in range(n+1)]

for c in range(C+1):
  for b in range(B+C+1-c):
    for a in range(A+B+C+1-c-b):
      if a == b == c == 0:continue
      result = n
      result += (dp[a-1][b][c]*a if a-1 >= 0 else 0)
      result += (dp[a+1][b-1][c]*b if b-1 >= 0 else 0)
      result += (dp[a][b+1][c-1]*c if c-1 >= 0 else 0)
      dp[a][b][c]=result / (a+b+c)

print(dp[A][B][C])



### FIXED CODE ###

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

S = [0] * 3
for a in A:
  S[a-1] += 1
I, J, K = S

dp = [[[0.0] * (N+1) for j in range(N+1)] for i in range(N+1)]

for k in range(S[2] + 1):
  for j in range(S[1] + S[2] - k + 1):
    for i in range(S[0] + S[1] + S[2] - j - k + 1):
      if i == j == k == 0: continue
      dp[i][j][k] = (i * (dp[i-1][j][k] if i > 0 else 0) + j * (dp[i+1][j-1][k] if j > 0 else 0) + k * (dp[i][j+1][k-1] if k > 0 else 0) + N) / (i + j + k)

print(dp[I][J][K])
### BUGGY CODE ###

MOD = 998244353

class Factorial:
    def __init__(self, n, mod):
        self.f = [1]
        self.mod = mod
        for j in range(1, n + 1):
            self.f.append(self.f[-1] * j % mod)
        self.i = [pow(self.f[-1], mod - 2, mod)]
        for j in range(n, 0, -1):
            self.i.append(self.i[-1] * j % mod)
        self.i.reverse()
    def factorial(self, j):
        return self.f[j]
    def ifactorial(self, j):
        return self.i[j]
    def comb(self, n, k):
        return self.f[n] * self.i[n - k] % self.mod * self.i[k] % self.mod if n >= k else 0

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

n = 2 * min(K // A + 2, N + 1) + 3

lst = Factorial(N + 1, MOD) #O(N)
N_factrorial = lst.factorial(N)
l_ifactorial = lst.ifactorial
# print (N_factrorial)

def calc(a, b):
    tmp = 0
    G = min(a, b) #緑色の最大値
    # print ('G=', G)
    for green in range(G, -1, -1):
        red = a - green
        blue = b - green
        none_color = N - red - green - blue
        # print (red, green, blue, none_color)
        if none_color < 0:
            break
        tmp += ((((N_factrorial * l_ifactorial(red) % MOD) * l_ifactorial(green) % MOD) * l_ifactorial(blue) % MOD) * l_ifactorial(none_color) % MOD)
        tmp %= MOD
    return tmp

def count(a, b):
    if a + b > 2 * N:
        return 0
    # print ('to calc')
    return calc(a, b)

ans = 0
for a in range(n): #Aの数
    if A * a > K:
        break
    if (K - A * a) % B != 0:
        continue
    b = (K - A * a) // B
    # print ('a=', a, 'b=', b)
    ans += count(a, b)
    ans %= MOD

print (ans)

### FIXED CODE ###

import numpy as np
MOD = 998244353

class Factorial:
    def __init__(self, n, mod):
        self.f = [1]
        self.mod = mod
        for j in range(1, n + 1):
            self.f.append(self.f[-1] * j % mod)
        self.i = [pow(self.f[-1], mod - 2, mod)]
        for j in range(n, 0, -1):
            self.i.append(self.i[-1] * j % mod)
        self.i.reverse()
    def factorial(self, j):
        return self.f[j]
    def ifactorial(self, j):
        return self.i[j]
    def comb(self, n, k):
        return self.f[n] * self.i[n - k] % self.mod * self.i[k] % self.mod if n >= k else 0

def gcd(a, b):
    if a > b:
        a, b = b, a
    if b % a == 0:
        return a
    return gcd(b % a, a)

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

if A < B:
    A, B = B, A

# n = 2 * min(K // A + 2, N + 1) + 3
n = min((K + A - 1) // A, N) + 1
lcm = A * B // gcd(A, B)
step = lcm // A

c = Factorial(N + 1, MOD).comb #O(N)

def calc(a, b):
    if a > b:
        a, b = b, a #必ずaのほうが小さくなる
    return (c(N, a) * c(N, b)) % MOD


def count(a, b):
    if a <= N and b <= N:
        return calc(a, b)
    return 0

def maike_satrt(step):
    for i in range(step):
        if (K - A * i) % B == 0:
            return i

start = maike_satrt(step)
# print (start, n)
ans = 0
for a in range(start, n, step): #Aの数
    if A * a > K:
        break
    # if (K - A * a) % B != 0:
    #     continue
    b = (K - A * a) // B
    # print ('a=', a, 'b=', b)
    ans += count(a, b)
    ans %= MOD

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

import math

K = int(input())

ans = 0

for h in range(1, K+1):
  for i in range(1, K+1):
    for j in range(1, K+1):
      ans += math.gcd(h, math.gcd(i, j))

print(ans)

### FIXED CODE ###

from math import gcd

K = int(input())

ans = 0

for h in range(1, K+1):
  for i in range(1, K+1):
    for j in range(1, K+1):
      ans += gcd(h, gcd(i, j))

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

N = int(input())
List = list(map(int, input().split()))
a=1

for i in range(N):
    a=a*List[i]
#print(a)
if a>10**18:
    print('-1')
else:
    print(a)

### FIXED CODE ###

N = int(input())
List = list(map(int, input().split()))
a=1
if  0 in List:
    print(0)

else:
    for i in List:
        a=a*i
        if a>10**18:
            print('-1')
            break
if not a>10**18 and not 0 in List:
    print(a)
### BUGGY CODE ###

from collections import Counter

n = int(input())
s = [Counter(input()) for _ in range(n)]

ans = 0
for i in range(n):
    for j in range(i + 1, n):
        if s[i] == s[j]:
            ans += 1

print(ans)


### FIXED CODE ###

from collections import Counter

n = int(input())
s = [list(input()) for _ in range(n)]


for i in range(n):
    s[i].sort()
    s[i] = "".join(s[i])

c = Counter(s)

ans = 0

for v in c.values():
    ans += v * (v - 1) // 2
print(ans)
### BUGGY CODE ###

def do(s, query, isReverse):
    if(query[0] == "1"):
        return s, isReverse * -1
    else:
        if(query[1] == "1"):
            if(isReverse == 1):
                return "".join([s, query[2]]), isReverse
            else:
                return "".join([query[2], s]), isReverse
        else:
            if(isReverse == 1):
                return "".join([query[2], s]), isReverse
            else:
                return "".join([s, query[2]]), isReverse

s = input()
q = int(input())
isReverse = -1
for i in range(q):
    query = input().split()
    s, isReverse = do(s, query, isReverse)
if(isReverse == -1):
    print(s)
else:
    print(s[::-1])

### FIXED CODE ###

s = input()
q = int(input())

ans = [" " for n in range(2*q + 1)]
ans[q] = s
frontIndex = q - 1
endIndex = q + 1
isReverse = -1

for i in range(q):
    query = input().split()
    if(query[0] == "1"):
        isReverse *= -1
    else:
        if(query[1] == "1"):
            if(isReverse == 1):
                ans[endIndex] = query[2]  
                endIndex += 1
            else:
                ans[frontIndex] = query[2]
                frontIndex -= 1
        else:
            if(isReverse == 1):
                ans[frontIndex] = query[2] 
                frontIndex -= 1
            else:
                ans[endIndex] = query[2]
                endIndex += 1
ans = "".join(ans).strip()
if(isReverse == -1):
    print(ans)
else:
    print(ans[::-1])
### BUGGY CODE ###

n,q=map(int,input().split())
s=input()

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

for j in range(n):
    if s[j]=="C" and j!=0 and s[j-1]=="A":
        dp[0][j]=dp[0][j-1]+1
    else:
        dp[0][j]=dp[0][j-1]

for i in range(1,n):
    if s[i]=="C" and s[i-1]=="A":   
        dp[i][i:n]=list(map(lambda x: x-1,dp[i-1][i:n]))
    else:
        dp[i][i:n]=dp[i-1][i:n]       
        
        
for i in range(q):
    l,r=map(int,input().split())
    print(dp[l-1][r-1])


### FIXED CODE ###

n,q=map(int,input().split())
s=input()
    
dp =[0 for j in range(n)]


for j in range(n):
    t=0
    if s[j]=="C" and j!=0:
        if s[j-1]=="A":
            t=1

    dp[j]=dp[j-1]+t
        

for i in range(q):
    l,r=map(int,input().split())
    print(dp[r-1]-dp[l-1])
### BUGGY CODE ###

N = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

flag = "Yes"
for i in range(N):
   A_max = max(a)
   B_max = max(b)
   if A_max > B_max:
      flag = "No"
   else:
      del a[a.index(A_max)]
      del b[b.index(B_max)]

print(flag)


### FIXED CODE ###

N = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

c = 0
for i in range(N):
   if b[i] - a[i] > 0:
      c += (b[i] - a[i])//2
   elif b[i] - a[i] < 0:
      c += b[i] - a[i]

if c >= 0:
   print("Yes")
else:
   print("No")
### BUGGY CODE ###

import sys
input=sys.stdin.readline
#グラフの連結成分を調べる
def Graph(ab):
    G=[[] for i in range(n)]
    for a,b in ab:
        G[a-1].append(b)
        G[b-1].append(a)
    return G
from collections import deque
def dfs(G,v,p):
    q=deque()
    q.append((v,p))
    log=[False]*n
    log[v-1]=True
    while q:
        V,P=q[-1]
        for new_v in G[V-1]:
            if new_v==P:continue
            if log[new_v-1]:continue
            log[new_v-1]=True
            score[new_v-1]+=score[V-1]
            q.append((new_v,V))
            break
        else:
            q.pop()


n,q=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n-1)]

score=[0]*n
for i in range(q):
    p,x=map(int,input().split())
    score[p-1]+=x

G=Graph(ab)
#print(G,score,sep='\n')
dfs(G,1,-1)
print(*score)

### FIXED CODE ###

n,q=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n-1)]
px=[list(map(int,input().split())) for i in range(q)]

#グラフの状態を調べる
def Graph(ab):
    G=[[] for i in range(n)]
    #up_G=[0]*n#up_G[i]=頂点iの親
    for a,b in ab:
        G[a-1].append(b-1)
        G[b-1].append(a-1)
    return G

from collections import deque
def bfs(G,v,p):
    #(G,v,p)=(グラフ(木の情報),探索中の頂点,vの親)
    #vの子の頂点を決めて、vをpに移す
    q=deque()
    q.append((v,p))
    while q:
        V,P=q.popleft()
        for new_v in G[V]:
            #new_vが頂点の時はアウト
            if new_v==P:continue
            ans[new_v]+=ans[V]
            q.append((new_v,V))

G=Graph(ab)
ans=[0]*n
#print(G)

for p,x in px:
    ans[p-1]+=x
bfs(G,0,-1)
print(*ans)
### BUGGY CODE ###

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

for i in range(len(a)):
    new_a.append(str(a.index(i+1)+1))
    
print(" ".join(new_a))

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
new_a = list("0"*len(a))

for i, a_i in enumerate(a):
    new_a[a_i-1] = str(i+1)
    
print(" ".join(new_a))
### BUGGY CODE ###

import math
import copy


def nCast(number):
    if type(number)==str:
        return int(number)
    for idx in range(0,len(number)):
        if type(number[idx])==str:

            number[idx]=int(number[idx])
        else:
            nCast(number[idx])
    return number
    
def inputArr(w):
    l=list()
    for idx in range(0,w):
        l.append(input())
    return l
def inputArr1(w):
    l=list()
    for idx in range(0,w):
        l.append(input().split())
    return l

n=nCast(input())
a=nCast(inputArr1(n))

b=copy.deepcopy(a)


def akey(a):
    return a[0],a[1]
def bkey(a):
    return a[1],a[0]
list.sort(a,key=akey,reverse=True)
list.sort(b,key=bkey,reverse=True)


def func(a,b):
    pa,pb=0,0
    tag=True
    while len(a)!=0:
        if a[0]==b[0]:
            tmp=a[0]
        else:
            v1=a[0][0]-b[0][1]
            v2=b[0][0]-b[1][1]
            if v1>v2:
                tmp=a[0]
            else:
                tmp=b[0]
        if tag:
            pa+=tmp[0]
        else:
            pb+=tmp[1]
        tag=not tag
        a,b=b,a
        a.remove(tmp)
        b.remove(tmp)
    return pa-pb
    
print(func(a,b)) 







### FIXED CODE ###

import math
import copy

def nCast(number):
    if type(number)==str:
        return int(number)
    for idx in range(0,len(number)):
        if type(number[idx])==str:

            number[idx]=int(number[idx])
        else:
            nCast(number[idx])
    return number
    
def inputArr(w):
    l=list()
    for idx in range(0,w):
        l.append(input())
    return l
def inputArr1(w):
    l=list()
    for idx in range(0,w):
        l.append(input().split())
    return l

n=nCast(input())
a=nCast(inputArr1(n))

def akey(a):
    return a[0]+a[1]
list.sort(a,key=akey,reverse=True)


def func(a):
    pa,pb=0,0
    tag=True
    for idx in range(0,len(a)):
        if tag:
            pa+=a[idx][0]
        else:
            pb+=a[idx][1]
        tag=not tag
    return pa-pb
    
print(func(a))
### BUGGY CODE ###

N, M = map(int, input().split())
MOD = 10 ** 9 + 7
ng = list([int(input()) for _ in range(M)])
ans = [0, 1] 
for i in range(1, N+1):
  if i in ng:
    ans.append(0)
  else:
    ans.append((ans[-2] + ans[-1]) % MOD)
print(ans[-1] % MOD)



### FIXED CODE ###

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

N = int(input())
black1 = ["AGC", "GAC", "ACG"]
black2 = ["AAGC", "ACGC", "AGGC", "ATGC",
        "AGAC", "AGCC", "AGGC", "AGTC"]

def func(S):
    if S[-3:] in black1:
        return 0
    if S[-4:] in black2:
        return 0
    else:
        if len(S)-3==N:
            return 1
        return func(S+"A") + func(S+"C") + func(S+"G") + func(S+"T")


print(func("___"))

### FIXED CODE ###

N = int(input())
black1 = ["AGC", "GAC", "ACG"]
black2 = ["AAGC", "ACGC", "AGGC", "ATGC",
        "AGAC", "AGCC", "AGGC", "AGTC"]
memo = [{} for _ in range(N+1)]

def func(cur, S):
    if S[-3:] in black1:
        return 0
    if S[-4:] in black2:
        return 0
    if S[-3:] in memo[cur]:
        return memo[cur][S[-3:]]
    else:
        if cur==N:
            return 1
        ret = 0
        for s in "ACGT":
            ret = ret + func(cur+1, S+s)
        memo[cur][S[-3:]] = ret
        return ret


print(func(0, "____")%(10**9+7))
### BUGGY CODE ###

N = int(input())
A = [0]*N

for i in range(N):
  A[i] = int(input())

  M = max(A)
for i in range(N):
  if M == A[i]:
    Atmp = A[0:i]
    Atmp.extend(A[i+1:N])
    ans = max(Atmp)
    print(ans)
  else:
    print(M)


### FIXED CODE ###

N = int(input())
A = [0]*N

for i in range(N):
  A[i] = int(input())

As = sorted(A, reverse=True)
M = As[0]
Ms = As[1]

for i in range(N):
  if M == A[i]:
    print(Ms)
  else:
    print(M)
### BUGGY CODE ###

N = int(input())
A = (int(x) for x in input().split())
sum  = 1
for i in A:
    sum = sum * i
if(sum > (10**18)):
    print(-1)
else:
    print(sum)


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
sum  = 1
flag = 0
for i in A:
    if(i == 0):
        print(0)
        flag=2
        break
if(flag==0):
    for i in A:
        sum = sum * i
        if(sum > 10**18):
            flag=1
            break
if(flag==0):
    print(sum)
elif(flag==1):
    print(-1)