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

import sys
sys.setrecursionlimit(200000)

N, M = list(map(int, input().split()))
alist = []
for m in range(M) :
    alist.append(int(input()))

def stairs(n, a1, a2) :
    a0 = (a1 + a2)*int(n not in alist)%1000000007
    if n == N :
        return a0
    else :
        return stairs(n+1, a0, a1)
      
print(stairs(1, 1, 0))

### FIXED CODE ###

from functools import lru_cache
from sys import setrecursionlimit

n, m = map(int, input().split())
a = set(int(input()) for _ in range(m))

mod = 10**9+7
setrecursionlimit(mod)

@lru_cache(maxsize=n)
def stairway(i) :
    if i in a :
        return 0
    elif i == 0 :
        return 1
    elif i == 1 :
        return stairway(0)
    else :
        return (stairway(i-1)+stairway(i-2))%mod
    
print(stairway(n))
### BUGGY CODE ###

def main():
    n = int(input())
    s = ["".join(sorted(input())) for i in range(n)]
    ss = set(s)
    res = 0
    if len(s) == len(ss):
        print(0)
        return
    for i in ss:
        cnt = s.count(i) - 1
        res += (cnt+1)*cnt//2
    print(res)
    
if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    n = int(input())
    s = ["".join(sorted(input())) for i in range(n)]
    
    from collections import Counter
    c = Counter(s)
    res = 0
    for i in c.values():
        if i < 2:
            continue
        else:
            res += i * (i-1) // 2
    print(res)
    
if __name__ == '__main__':
    main()
### BUGGY CODE ###

import sys
import numpy as np

input=sys.stdin.readline

N, M = [int(x) for x in input().split()]
A = []
for _ in range(N):
    A.append([int(x) for x in input().split()])

total = 0

for x in range(1, M + 1):
    max = 0
    max_index = -1
    for y, row in enumerate(A):
        if row[0] <= x and row[1] > max:
            max = row[1]
            max_index = y
    if max_index != -1:
        total += max
        A.pop(max_index)

print(total)





### FIXED CODE ###

from collections import defaultdict
import heapq

N, M = [int(x) for x in input().split()]

dict = defaultdict(list)
for _ in range(N):
    A, B = [int(x) for x in input().split()]
    dict[A].append(B)

h = []
total = 0
for x in range(1, M + 1):
    for y in dict[x]:
        heapq.heappush(h, -y)
    if h:
        total += heapq.heappop(h)

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

n, m = map(int, input().split())
value = []
for i in range(m):
    A, B = map(int, input().split())
    C = list(map(int, input().split()))
    binary = 0
    for c in C:
        binary += 1<<(c-1)
    value.append([A, binary])
    
dp = [100100100] * (1<<n)
dp[0] = 0
for s in range(1<<n):
    for i in range(m):
        t = s | value[i][1]
        cost = dp[s] + value[i][0]
        dp[t] = min(dp[t], cost)
if dp[(1<<n)-1] == 100100100:
    print(-1)
else:
    print(dp[(1<<n)-1])

### FIXED CODE ###

#import sys
#input = sys.stdin.readline
 
n, m = map(int, input().split())
value = []
for i in range(m):
    A, B = map(int, input().split())
    c = sum(1<<(ci-1) for ci in map(int, input().split()))
    value.append([A, c])
    
dp = [100100100] * (1<<n)
dp[0] = 0
for s in range(1<<n):
    for i in range(m):
        t = s | value[i][1]
        cost = dp[s] + value[i][0]
        if dp[t] > cost:
            dp[t] = cost
        
if dp[(1<<n)-1] == 100100100:
    print(-1)
else:
    print(dp[(1<<n)-1])
### BUGGY CODE ###

inputlist = list(map(int, input().split()))
n, m = inputlist[0], inputlist[1]

for i in range(n, m+1):
    if m % i != 0:
        continue
    print(m // i)
    break

### FIXED CODE ###

def f():
  n, m = map(int, input().split())
  for i in range(m//n+1)[::-1]:
    if m%i==0:return i
print(f())
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
d = []
count = 0
for el in a:
    temp = a.count(el)
    count += temp-1
    d.append(temp)
count //= 2
for el in d:
    print(count - el + 1)


### FIXED CODE ###

from collections import Counter
n = int(input())
a = list(map(int, input().split()))
counter = Counter(a)
d = [0]*(n+1)
count = 0
for el, cnt in counter.most_common():
    d[el] = cnt
    count += cnt*(cnt-1)
count //= 2
for el in a:
    print(count - d[el] + 1)
### BUGGY CODE ###

import sys
import numpy as np
import fractions
 
from functools import reduce
 
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
 
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
 
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
 
def LI():
  return [int(s) for s in input().split()]
 
 
input = sys.stdin.readline
ri = lambda: int(input())
ril = lambda: list(map(int, input().split()))
 
N = ri()
A_s = ril()
mod = 10**9 + 7
 
l = lcm_list(A_s)
 
print(sum(map(lambda x : l//x, A_s)) % mod)

### FIXED CODE ###

import fractions
 
N = int(input())

def LI():
  return [int(s) for s in input().split()]

A_s = LI()
mod = 10**9 + 7

#l = lcm_list(A_s)
l = 1
for num in A_s:
    l = l * num // fractions.gcd(l,num)

count = 0
for a in A_s:
  count+=l//a
  
print(count % mod)
### BUGGY CODE ###

S = input()

result = 0
while True:
    if '01' in S:
        index = S.find('01')
        S = S[:index] + S[index+2:]
        result += 2
    elif '10' in S:
        index = S.find('10')
        S = S[:index] + S[index+2:]
        result += 2

    else:
        break

print(result)


### FIXED CODE ###

S = input()
 
num_0 = S.count('0')
num_1 = S.count('1')

print(min(num_0, num_1) * 2)
### BUGGY CODE ###

mod = 1000000007
N = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(N-1):
    for j in range(i+1,N):
        ans += A[i]*A[j]
        ans %= mod
print(ans)

### FIXED CODE ###

mod = 1000000007
N = int(input())
A = list(map(int,input().split()))
sum_a = sum(A)
ans = 0
for a in A:
    ans += a*(sum_a-a)
    #print(sum_a-a)
ans //= 2

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

import sys
input = sys.stdin.readline
import math
 
def INT(): return int(input())
def MAPINT(): return map(int, input().split())
def LMAPINT(): return list(map(int, input().split()))
def STR(): return input()
def MAPSTR(): return map(str, input().split())
def LMAPSTR(): return list(map(str, input().split()))
 
f_inf = float('inf')
 
n = INT()
a = sorted(LMAPINT())

ans = [True] * n
for i in range(n):
  if ans[i] is False:
    continue
  for j in range(i+1, n):
    if a[j] % a[i] == 0:
      ans[j] = False
    if a[j] == a[i]:
      ans[i], ans[j] = False, False
 
print(ans.count(True))

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
 
xs = [0] * (max(a) + 1)
 
for v in a:
    if xs[v] == 0:
        for j in range(v, len(xs), v):
            xs[j] += 1
    else:
        xs[v] += 1
print(len(list(filter(lambda v: xs[v] == 1, a))))
### BUGGY CODE ###

X = list(input())
while True:
    before = len(X)
    for i in range(len(X) - 1):
        if X[i] == "S" and X[i + 1] == "T":
            del X[i:i + 2]
            break
    if len(X) == before:
        break     
print(len(X))


### FIXED CODE ###

X = input()
ans = 0

for c in X:
    if c == 'S':
        ans += 1
    if c == 'T' and ans > 0:
        ans -= 1
print(ans * 2)
### BUGGY CODE ###

# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
import sys
def main(N, K, A):
    st = SegmentTree(f=lambda x, y: x * y, identity_factory=lambda: 1, initial_values=A)
    prev = st.query(0, K)
    for i in range(K + 1, N + 1):
        curr = st.query(i - K, i)
        print('Yes' if curr > prev else 'No')
        prev = curr

class SegmentTree:
    def __init__(self, n=None, f=max, identity_factory=int, initial_values=None):
        assert(n or initial_values)
        size = n if n else len(initial_values)
        d = [identity_factory() for _ in range(2 * size + 1)]
        self.__n, self.__d, self.__f, self.__e = size, d, f, identity_factory
        if initial_values:
            for i, v in enumerate(initial_values): d[size + i] = v
            for i in range(size - 1, 0, -1): d[i] = f(d[i << 1], d[i << 1 | 1])

    def get_val(self, index):
        return self.__d[index + self.__n]

    def set_val(self, index, new_value):
        i, d, f = index + self.__n, self.__d, self.__f
        if d[i] == new_value: return
        d[i] = new_value
        while i:
            i = i >> 1
            d[i] = f(d[i << 1], d[i << 1 | 1])

    def modify(self, index, value):
        self.set_val(index, self.__f(self.__d[index + self.__n], value))

    def query(self, from_inclusive, to_exclusive):
        ans = self.__e()
        if to_exclusive <= from_inclusive: return ans
        l, r, d, f = from_inclusive + self.__n, to_exclusive + self.__n, self.__d, self.__f
        while l < r:
            if l & 1: ans, l = f(ans, d[l]), l + 1
            if r & 1: ans, r = f(d[r - 1], ans), r - 1
            l, r = l >> 1, r >> 1
        return ans

if __name__ == '__main__':
    input = sys.stdin.readline
    N, K = map(int, input().split())
    *A, = map(int, input().split())
    main(N, K, A)


### FIXED CODE ###

# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
import sys
def main(N, K, A):
    for i in range(K, N):
        print('Yes' if A[i] > A[i - K] else 'No')

if __name__ == '__main__':
    input = sys.stdin.readline
    N, K = map(int, input().split())
    *A, = map(int, input().split())
    main(N, K, A)
### BUGGY CODE ###

from collections import deque
n,k=map(int,input().split())
p = list(map(int,input().split()))
def ex_even(a):
    return (a+1)/2
def ex_odd(b):
    return b//2 + 1
ans = [0] * k
q = deque(ans)
c_max = 0
for i in range(1,n+1):
    if p[i-1] % 2 == 0:
        ex = ex_even(p[i-1])
        q.popleft()
        q.append(ex)
    else:
        ex = ex_odd(p[i-1])
        q.popleft()
        q.append(ex)
    c_max = max(c_max, sum(q))
print(c_max)

### FIXED CODE ###

n,k=map(int,input().split())
p = list(map(int,input().split()))
def ex_even(a):
    return (a+1)/2
def ex_odd(b):
    return b//2 + 1
s = sum(p[0:k])
s_max = sum(p[0:k])
for i in range(n-k):
    s = s-p[i] + p[i+k]
    s_max = max(s_max,s)
if s_max % 2 == 0:
    print(ex_even(s_max) + 0.5*(k-1))
else:
    print(ex_odd(s_max) + 0.5*(k-1))
### BUGGY CODE ###

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

### FIXED CODE ###

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

import sys
sys.setrecursionlimit(10 ** 6)

inputs = [int(x) for x in input().split()]
n, m = inputs[0], inputs[1]
conditions = {}
for i in range(n):
  inputs = [int(x) for x in input().split()]
  if inputs[0] in conditions.keys():
    conditions[inputs[0]].append(inputs[1])
  else:
    conditions[inputs[0]] = [inputs[1]]

for day in conditions.keys():
  conditions[day].sort(reverse=True)

ans = 0
candidates = []
for reversed_day in range(1, m + 1):
  if reversed_day in conditions.keys():
    candidates.append(conditions[reversed_day])

  cand_len = len(candidates)
  if cand_len == 0:
    continue
  maxval, maxidx = 0, 0
  for i, cands in enumerate(candidates):
    if cands[0] > maxval:
      maxval = cands[0]
      maxidx = i
  ans += candidates[maxidx].pop(0)
  if len(candidates[maxidx]) == 0:
    del candidates[maxidx]
print(ans)


### FIXED CODE ###


import collections
import heapq

inputs = [int(x) for x in input().split()]
n, m = inputs[0], inputs[1]
conditions = collections.deque([])
for i in range(n):
  conditions.append([int(x) for x in input().split()])

conditions = sorted(conditions)

cnt, ans = 0, 0
candidates = []
for reversed_day in range(1, m + 1):
  while cnt < len(conditions) and conditions[cnt][0] <= reversed_day:
    heapq.heappush(candidates, -conditions[cnt][1])
    cnt += 1

  if len(candidates) == 0:
    continue
  ans -= heapq.heappop(candidates)

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

#標準入力
X = int(input())

max_beki = 1
for i in range(1,X):
  for j in range(2,X):
    beki = i ** j
    
    if beki > max_beki:
      if beki <= X:
        max_beki = beki
 
print(max_beki)


### FIXED CODE ###

#標準入力
X = int(input())

max_beki = 1
for i in range(1,X):
  for j in range(2,X):
    beki = i ** j
    
    if beki > X:
      break
      
    elif beki > max_beki:
      max_beki = beki
 
print(max_beki)
### BUGGY CODE ###

# import bisect
# import copy
from fractions import gcd


# import math
# import numpy as np
# from collections import Counter, deque
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
import sys
sys.setrecursionlimit(10**9)


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

    # A[0:i]の最大公約数
    def L(i):
        if i == 0:
            return 0
        return gcd(L(i - 1), A[i - 1])

    # A[i:]の最大公約数
    def R(i):
        if i == N:
            return 0
        return gcd(R(i + 1), A[i])

    maxgcd = 0
    for i in range(N):
        maxgcd = max(maxgcd, gcd(L(i), R(i + 1)))

    print(maxgcd)


resolve()

### FIXED CODE ###

# import bisect
# import copy
from fractions import gcd


# import math
# import numpy as np
# from collections import Counter, deque
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
import sys
sys.setrecursionlimit(10**9)


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

    # A[0:i]の最大公約数
    L=[0]*N
    for i in range(1,N):
        L[i]=gcd(L[i - 1], A[i - 1])

    # A[i:]の最大公約数
    R=[0]*(N+1)
    for i in reversed(range(N)):
        R[i]=gcd(R[i + 1], A[i])


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

    print(maxgcd)


resolve()
### BUGGY CODE ###

from collections import Counter
from itertools import combinations

n = int(input())
s = []
for _ in range(n):
    s.append(input())

cnt = 0
for t, u in combinations(s, 2):
    if Counter(t) == Counter(u):
        cnt += 1

print(cnt)


### FIXED CODE ###

from collections import Counter
from math import factorial

def count_combinations(n, r):
    return factorial(n) // (factorial(r) * factorial(n-r))

n = int(input())
s = []
for _ in range(n):
    s.append(input())

t = [''.join(sorted(str)) for str in s]
c = Counter(t)
ll = [i for _, i in c.items() if i > 1]
cnt = 0
for i in ll:
    cnt += count_combinations(i, 2)

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

N = int(input())
S = list(input())
def have_c(c):
    if(c=='R'):
        return 4
    elif(c=='G'):
        return 2
    elif(c=='B'):
        return 1
    return 0

def have_n(n):
    if(n==4):
        return 'R'
    elif(n==2):
        return 'G'
    elif(n==1):
        return 'B'
    return 0
    
ans = 0
for i in range(N-3):
    for j in range(i+1,N-1):
        hav = have_c(S[i])
        if(hav == have_c(S[j])):
            continue
        hav += have_c(S[j])
        last_alpha = have_n(7-hav)
        for k in range(j+1,N):
            if(j-i == k-j):
                continue
            if(S[k]==last_alpha):
                ans +=1
print(ans)

### FIXED CODE ###

N = int(input())
S = list(input())
r = S.count('R')
g = S.count('G')
b = S.count('B')
cnt=0
for i in range(N-2):
    for j in range(i+1,N-1):
        if(j+(j-i) >= N):
            break
        if((S[j+(j-i)] != S[i]) and (S[j+(j-i)] != S[j]) and (S[i] != S[j])):
            cnt += 1
print(r*g*b-cnt)
### BUGGY CODE ###

from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))


n = inp()
a = inpl()
g = 1
res = 0
for i in a:
    g = i*g//fractions.gcd(i,g)
for i in a:
    res += g//i
print(res%mod)


### FIXED CODE ###

from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))


n = inp()
a = inpl()
g = 1
res = 0
for i in a:
    g = i*g//fractions.gcd(i,g)
for i in a:
    res += g//i
print(res%mod)
### BUGGY CODE ###

import itertools
import sys
import math
import fractions
import numpy as np
from collections import deque
from itertools import combinations
from functools import reduce
from functools import lru_cache
sys.setrecursionlimit(10**9)

def get_lcm(num):
    return reduce(lambda x,y:(x * y) // fractions.gcd(x, y), num, 1)

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

    lcm = get_lcm(A)
    _, ans = divmod(sum(list(map(lambda a: lcm // a ,A))), (10**9+7))

    print(ans)

if __name__ == "__main__":
  main()


### FIXED CODE ###

import itertools
import sys
import math
import fractions
from collections import deque
from itertools import combinations
from functools import reduce
from functools import lru_cache
sys.setrecursionlimit(10**9)

def get_lcm(num):
    return reduce(lambda x,y:(x * y) // fractions.gcd(x, y), num, 1)

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

    lcm = get_lcm(A)
    sum = 0
    for a in A:
      sum += lcm // a
    _, ans = divmod(sum, (10**9+7))

    print(ans)

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

import sys
sys.setrecursionlimit(500000)
input = sys.stdin.readline
N = int(input()); MOD=pow(10,9)+7

beki = [-1]*(N+1); beki[0] = 1; beki[1] = 2 #階乗
for i in range(2,N+1):
  beki[i] = beki[i-1]*2%MOD
#print(beki)

G = [[] for _ in range(N)]
for i in range(N-1):
  a,b = map(int,input().split())
  a-=1;b-=1
  G[a].append(b);G[b].append(a)
#print(G)
ans = 0

def dfs(v,p): #自分と親
  global ans #ansをGlobal変数として宣言
  res = 1 #戻り値。vを含めた部分木のサイズ。自分の分で最初は1
  ts = [] #vから生えている部分木のリスト
  for u in G[v]:
    if u == p:
      continue
    t = dfs(u,v) #uの部分木のサイズが戻り値
    res += t
    ts.append(t)
  if p != -1: #根以外なら親側の部分木が存在する。
    ts.append(N-res)
  now = beki[N-1] - 1 #自分以外を決めるのが2^(N-1)通り。自分以外が全部0が1通り。
  for x in ts:
    now -= beki[x] - 1 #各部分木に一個以上黒がある場合の数。全通り - 全部白
  ans = (ans+now)%MOD
  return res #vを含めた部分木のサイズ

dfs(0,-1)
ALL = beki[N]
#print(ans,ALL)
ans = ans*pow(ALL,MOD-2,MOD)%MOD #フェルマーの小定理より1/ALL = ALL^(MOD-2)
print(ans)
           

### FIXED CODE ###

import sys
sys.setrecursionlimit(500000)
input = sys.stdin.readline
N = int(input()); MOD=pow(10,9)+7
G = [[] for _ in range(N)]
for i in range(N-1):
  a,b = map(int,input().split())
  a-=1;b-=1
  G[a].append(b);G[b].append(a)
#print(G)
ans = 0

def dfs(v,p): #自分と親
  global ans #ansをGlobal変数として宣言
  res = 1 #戻り値。vを含めた部分木のサイズ。自分の分で最初は1
  ts = [] #vから生えている部分木のリスト
  for u in G[v]:
    if u == p:
      continue
    t = dfs(u,v) #uの部分木のサイズが戻り値
    res += t
    ts.append(t)
  if p != -1: #根以外なら親側の部分木が存在する。
    ts.append(N-res)
  now = pow(2,N-1,MOD) - 1 #自分以外を決めるのが2^(N-1)通り。自分以外が全部0が1通り。
  for x in ts:
    now -= pow(2,x,MOD) - 1 #各部分木に一個以上黒がある場合の数。全通り - 全部白
  ans = (ans+now)%MOD
  return res #vを含めた部分木のサイズ

dfs(0,-1)
ALL = pow(2,N,MOD)
#print(ans,ALL)
ans = ans*pow(ALL,MOD-2,MOD)%MOD #フェルマーの小定理より1/ALL = ALL^(MOD-2)
print(ans)
### BUGGY CODE ###

from collections import deque
n=int(input())
a=[int(input()) for i in range(n)]
A=deque(a)
tmp=[]
while A:
    if A[0] in tmp:
        tmp.remove(A.popleft())
    else:
        tmp.append(A.popleft())
print(len(tmp))

### FIXED CODE ###

n=int(input())
A=set()
for i in range(n):
    a=input()
    if a in A:
        A.remove(a)
    else:
        A.add(a)
print(len(A))
### BUGGY CODE ###

n1, n2 = [int(i) for i in input().split()]

r1 = 2018
for i3 in range(n2 - n1):
    n4 = i3 + n1

    t1 = n2 -n4
    if t1 >= 2019:
        t1 = 2019
    for i5 in range(t1):
        n5 = i5 + n4 + 1

        if ((n4 * n5) % 2019)  < r1:
            r1 = ((n4 * n5) % 2019)

print(r1)

### FIXED CODE ###

import sys

n1, n2 = [int(i) for i in input().split()]

r1 = 2018

if n2 - n1 >= 2019:
    print(0)
    sys.exit()


for i3 in range(n2 - n1):
    n4 = i3 + n1

    t1 = n2 - n4
    if t1 >= 2019:
        t1 = 2019
    for i5 in range(t1):
        n5 = i5 + n4 + 1

        if ((n4 * n5) % 2019)  < r1:
            r1 = ((n4 * n5) % 2019)

print(r1)
### BUGGY CODE ###

import functools
import operator
prod = functools.partial(functools.reduce, operator.mul)
n = int(input())
a = list(map(int, input().split()))
res = prod(a)
if(res > 10**18):
    print(-1)
else:
    print(res)

### FIXED CODE ###

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

n=int(input())
a=list(map(int,input().split()))
p=1
s=0
t=0
if 0 in a:
    t=1
else:
    t=0
for i in range(0,n):
    if s==0 or t==1:
        p=p*a[i]
        if p >10**18:
            s=1
            p=-1
        else:
            continue
    else:
        break
print(p)

### FIXED CODE ###

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

A = list(input())

S = [0]


for n in range(1, len(A)+1):
    S.append(S[-1] + (int(A[-n])*(10**(n-1))))

result = 0

for i in range(len(S)):
    i = i + 1
    for j in range(len(S)-i):
        if S[-i] == S[-j]:
            continue
        if (S[-i] - S[j]) % 2019 == 0:
            result += 1


print(result)


### FIXED CODE ###

S = input()
 
res = [0] * 2019
res[0] = 1
 
d = 1
a = 0
 
for c in reversed(S):
    a += int(c) * d
    a %= 2019
    res[a] += 1
    d *= 10
    d %= 2019
 
ans = 0
for r in res:
    ans += r*(r-1) // 2
print(ans)
### BUGGY CODE ###

h, w = map(int, input().split())
maze = []
for _ in range(h):
    maze.append(list(input()))
import collections
black = collections.deque([])
cnt = 0
for hh in range(h):
    for ww in range(w):
        if maze[hh][ww] == "#":
            cnt += 1
            black.append([hh, ww, 0])
dh = [ 0, -1, 1, 0]
dw = [ -1, 0, 0, 1]
res = 0
allcount = h*w
res = 0
while cnt < allcount:
    #print("black:", black)
    bh, bw , bturn= black.popleft()
    #print("pop", bh, bw, bturn)
    for di in range(len(dh)):
        nh = bh + dh[di]
        nw = bw + dw[di]
        if nh < 0 or nh > (h-1) or nw < 0 or nw > (w-1):
            continue
        if maze[nh][nw] == "#":
            continue
        black.append([nh, nw, bturn+1])
        #print(nh, nw)
        maze[nh][nw] = "#"
        res = max(res, bturn+1)
        cnt += 1
print(res)

### FIXED CODE ###

h, w = map(int, input().split())
maze = []
for _ in range(h):
    maze.append(list(input()))
import collections
black = collections.deque([])
cnt = 0
for hh in range(h):
    for ww in range(w):
        if maze[hh][ww] == "#":
            cnt += 1
            black.append([hh, ww, 0])
dh = [ 0, -1, 1, 0]
dw = [ -1, 0, 0, 1]
res = 0
allcount = h*w
res = 0
while cnt < allcount:
    #print("black:", black)
    bh, bw , bturn= black.popleft()
    #print("pop", bh, bw, bturn)
    for di in range(len(dh)):
        nh = bh + dh[di]
        nw = bw + dw[di]
        if nh < 0 or nh > (h-1) or nw < 0 or nw > (w-1):
            continue
        if maze[nh][nw] == "#":
            continue
        black.append([nh, nw, bturn+1])
        #print(nh, nw)
        maze[nh][nw] = "#"
        res = max(res, bturn+1)
        cnt += 1
print(res)