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

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

import math
from functools import reduce

def gcd_list(numbers):
  return reduce(math.gcd, numbers)

def sieve_of_eratosthenes(n): 
    candidate = [i for i in range(2, n+1)] 
    prime = []
    limit = math.sqrt(n) + 1 

    while True:
        p = min(candidate) 
        if limit <= p:
            prime.extend(candidate) 
            break
        prime.append(p) 

        candidate = [i for i in candidate if i % p != 0]

    return prime

prime = sieve_of_eratosthenes(2*(10**5)+1)

g = math.gcd(A[0],A[1])
for a in A[2:]:
  g = math.gcd(g,a)


for p in prime:
  cnt = 0
  for a in A:
    if a%p == 0: cnt += 1
    if cnt == 2:
      if g == 1: print('setwise coprime')
      else: print('not coprime')
      exit()
print('pairwise coprime')



### FIXED CODE ###

import math
from functools import reduce

def gcd_list(numbers):
  return reduce(math.gcd, numbers)

N=int(input())
A=list(map(int,input().split()))
mA = max(A)
D = [-1]*(mA+1)
D[0]=1
D[1]=1
for i in range(2,mA+1):
  if D[i] != -1: continue
  D[i] = i
  cnt = 2*i
  while cnt < mA+1:
    if D[cnt] == -1:
      D[cnt]=i
    cnt += i
done = set()
for a in A:
  tmp = set()
  while a > 1:
    tmp.add(D[a])
    a //= D[a]
  if len(done&tmp) > 0:
    if gcd_list(A) == 1: print('setwise coprime')
    else: print('not coprime')
    exit()
  done |= tmp
print('pairwise coprime')
### BUGGY CODE ###

#TLE
n, a, b = map(int, input().split())

#　ans = 2**n
na = list(bin(n))
nb = na[3:]

ans = 2

for c in nb:
    if c == '0':
        ans **= 2
    else:
        ans = (ans ** 2) * 2

if n == 0:
    ans = 1

#　数え過ぎたものを引く
def comb(n, r):
    m = 1
    for i in range(n-r+1, n+1):
        m *= i
    for i in range(1, r+1):
        m //= i
    return m
ans -= comb(n, a) + comb(n, b) + 1

print(int(ans % (1000000007)))

### FIXED CODE ###

#TLE

#comb_mod(n, r, mod) = nCr % mod
def comb_mod(n, r, mod):
    ans = 1
    if r <= n/2:
        for i in range(n-r+1, n+1):
            ans *= i
            ans %= mod
        for i in range(1, r+1):
            ans *= pow(i, mod-2, mod)
            ans %= mod
    else:
        for i in range(r+1, n+1):
            ans *= i
            ans %= mod
        for i in range(1, n-r+1):
            ans *= pow(i, mod-2, mod)
            ans %= mod
    return ans

n, a, b = map(int, input().split())
ans = pow(2, n, 10**9+7) - comb_mod(n, a, 10**9+7) - comb_mod(n, b, 10**9+7) - 1
if ans < 0:
    ans += 10**9 + 7
if ans < 0:
    ans += 10**9 + 7

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

#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#

"""
ARC103 D
"""

from collections import deque
n = int(input())
xyli = deque([tuple(map(int,input().split())) for i in range(n)])

m = 20
dli = [1 for i in range(20)]

zli = list(map(lambda t:(t[0]+t[1])%2,xyli))

flag=True
if len(set(zli))>1:
    flag = False


oe = zli[0]



if flag:
    if oe==0:
        print(20)
        print(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1)
        for j in range(n):
            x,y=xyli.popleft()
            ans = []
            if x>0:
                ans = ans + ['R' for i in range(abs(x))]
            elif x<0:
                ans = ans + ['L' for i in range(abs(x))]
            if y>0:
                ans = ans + ['U' for i in range(abs(y))]
            elif y<0:
                ans = ans + ['D' for i in range(abs(y))]
            nn = (20-len(ans))//2
            ans = ans+['L' for i in range(nn)]
            ans = ans+['R' for i in range(nn)]
            print(''.join(ans))
    if oe==1:
        print(19)
        print(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1)
        for j in range(n):
            x,y=xyli.popleft()
            ans = []
            if x>0:
                ans = ans + ['R' for i in range(abs(x))]
            elif x<0:
                ans = ans + ['L' for i in range(abs(x))]
            if y>0:
                ans = ans + ['U' for i in range(abs(y))]
            elif y<0:
                ans = ans + ['D' for i in range(abs(y))]
            nn = (19-len(ans))//2
            ans = ans+['L' for i in range(nn)]
            ans = ans+['R' for i in range(nn)]
            print(''.join(ans))
else:
    print(-1)

    
            



### FIXED CODE ###

#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#

"""
ARC103 D
"""

from collections import deque
n = int(input())
xyli = deque([tuple(map(int,input().split())) for i in range(n)])

m = 20
dli = [1 for i in range(20)]

zli = list(map(lambda t:(t[0]+t[1])%2,xyli))

flag=True
if len(set(zli))>1:
    print(-1)
    exit()


oe = zli[0]

ans = []
dli = []
flag =False
if oe == 0:
    xyli = list(map(lambda t:(t[0]+1,t[1]),xyli))
    flag = True

uvli = list(map(lambda t:(t[0]+t[1],t[0]-t[1]),xyli))

def mode(ubin,vbin):
    if ubin and vbin:
        return('R')
    elif (not ubin) and vbin:
        return('D')
    elif ubin and (not vbin):
        return('U')
    else:
        return('L')

if flag:
    print(32)
    print(" ".join(map(str,[1]+[2**(30-i) for i in range(31)])))
else:
    print(31)
    print(" ".join(map(str,[2**(30-i) for i in range(31)])))

for u,v in uvli:
    ubin = format(((2**31-1)+u)//2,'031b')
    vbin = format(((2**31-1)+v)//2,'031b')
    if flag:
        print('L',end='')
    for i in range(31):
        print(mode(int(ubin[i]),int(vbin[i])),end='')
    print()
### BUGGY CODE ###

m = list(map(int,input().split()))
a=[int(input()) for i in range(m[2])]

n = [m[1]] * m[0]

for i in range(m[2]):
    n = [i-1 for i in n]
    n[a[i]-1] +=1
for i in range(m[0]):
    if n[i]>0:
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

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

for i in range(m[2]):
    n[int(input())-1] += 1
  
for i in range(m[0]):
    if n[i] - m[2] + m[1] > 0:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

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

MOD = 10**9+7

N, M = map(int, input().split())
S = list(map(int, input().split()))
T = list(map(int, input().split()))

X = [0]*(N+1)
X[0] = 1

for t in T:
    x = 1
    
    for i, s in enumerate(S):
        prevX = X[i+1]

        if t == s:
            X[i+1] += x

        x += prevX
        x %= MOD

print(sum(X)%MOD)


### FIXED CODE ###

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


def f(N, M, S, T):
    W = [1]*(N+1)

    for i, t in enumerate(T):
        W2 = W[:]
        
        k = 0
        for j, s in enumerate(S):
            if t == s:
                k += W[j]

            x = (W2[j+1] + k)%1000000007
            W2[j+1] = x

        W = W2
        
    return W[-1]



def main():
    N, M = map(int, input().split())
    S = list(map(int, input().split()))
    T = list(map(int, input().split()))

    print(f(N,M,S,T))



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

N,M=map(int,input().split())
A=list(map(int,input().split()))
q=[]
for i in range(M):
    q.append(list(map(int,input().split())))
    
sorted_q=sorted(q,key=lambda x:x[1],reverse=True)

q_all=[]
for i in range(M):
    for j in range(sorted_q[i][0]):
        q_all.append(sorted_q[i][1])

if len(A)<=len(q_all):
    A.sort()
    for i in range(N):
        if A[i]<q_all[i]:
            A[i]=q_all[i]
else:
    A.sort()
    for i in range(len(q_all)):
        if A[i]<q_all[i]:
            A[i]=q_all[i]
        
print(sum(A))


### FIXED CODE ###

n, m = map(int, input().split())
A = list(map(int, input().split()))
BC = [tuple(map(int, input().split())) for _ in range(m)]

A.sort()
BC.sort(key=lambda x: x[1], reverse=True)

cnt = 0
for b, c in BC:
    for i in range(b):
        if c < A[cnt]:
            break
        A[cnt] = c
        cnt += 1
        if cnt >= n:
            break
    else:
        continue
    break

print(sum(A))
### BUGGY CODE ###

from collections import deque

n = int(input())
x = eval('0b' + input())

memo = {0: 0}

def solve(X):
    x = X
    stack = deque([])
    while x:
        if x in memo:
            break
        stack.append(x)
        x = x % bin(x).count("1")
    cnt = memo[x] + 1
    while stack:
        x = stack.pop()
        memo[x] = cnt
        cnt += 1
    return cnt - 1



ans = []

for i in range(n):
    y = 0
    if x & (1 << i):
        y = x & ~(1 << i)
    else:
        y= x | (1 << i)
    ans.append(solve(y))

for ansi in reversed(ans):
    print(ansi)


    

        


### FIXED CODE ###

from collections import deque

n = int(input())
x = input()

memo = {0: 0}

def solve(X):
    x = X
    stack = deque([])
    while x:
        if x in memo:
            break
        stack.append(x)
        x = x % bin(x).count("1")
    cnt = memo[x] + 1
    while stack:
        x = stack.pop()
        memo[x] = cnt
        cnt += 1
    return cnt - 1



ans = []
px = x.count("1")

memo1 = [1 % (px - 1)] if px > 1 else []
memo2 = [1 % (px + 1)]
x1 = 0
x2 = 0

for i in range(n):
    if px > 1:
        memo1.append(memo1[-1] * 2 % (px-1))
    memo2.append(memo2[-1] * 2 % (px+1))

for i in range(n):
    if x[-i-1] == '1':
        if px > 1:
            x1 += memo1[i]
            x1 %= (px-1)
        x2 += memo2[i]
        x1 %= (px+1)

for i in range(n):
    if x[-i-1] == "1":
        if px > 1:
            ans.append(solve((x1-memo1[i])%(px-1)) + 1)
        else:
            ans.append(0)
    else:
        ans.append(solve((x2+memo2[i])%(px+1)) + 1)


for ansi in reversed(ans):
    print(ansi)
### BUGGY CODE ###

N, K, Q = map(int, input().split())
# print('N=', N, 'K=', K, 'Q=', Q)

participant_list = []
for i in range(N):
    participant_list.append(K)
# print(participant_list)

for i in range(Q):
#     print('num=', i)
    for i in range(N):
        participant_list[i] -= 1 
    answer = int(input()) - 1
    participant_list[answer] += 1
#     print(participant_list)

for i in range(N):
    if participant_list[i] <= 0:
        print('No')
    else:
        print('Yes')

### FIXED CODE ###

N, K, Q = map(int, input().split())
# print('N=', N, 'K=', K, 'Q=', Q)

participant_list = [K-Q] * N
# print(participant_list)

for i in range(Q):
    participant_list[int(input())-1] += 1
    
for i in participant_list:
    if i <= 0:
        print('No')
    else:
        print('Yes')
### BUGGY CODE ###

def match(c1, c2):
    return c1 == '?' or c1 == c2 or '?' == c2

a = input()
b = input()
c = input()
A, B, C = len(a), len(b), len(c)
ab, bc, ca = [True] * 20000, [True] * 20000, [True] * 20000

for i in range(A):
    for j in range(B):
        if not match(a[i], b[j]):
            ab[i - j + 10000]= False
for i in range(B):
    for j in range(C):
        if not match(b[i], c[j]):
            bc[i - j + 10000]= False
for i in range(C):
    for j in range(A):
        if not match(c[i], a[j]):
            ca[i - j + 10000]= False
ans = 6000

for i in range(-4000, 4000):
    for j in range(-4000, 4000):
        if ab[i + 10000] and bc[j-i+10000] and ca[-j+10000]:
            L = min(0, min(i, j))
            R = max(A, max(B+i, C+j))
            ans = min(ans, R-L)
print(ans)
    

### FIXED CODE ###

a = input()
b = input()
c = input()
A, B, C = len(a), len(b), len(c)
ab, bc, ac = [1] * 16000, [1] * 16000, [1] * 16000

for i in range(A):
    if a[i] == '?':
        continue
    for j in range(B):
        if b[j] != '?' and a[i] != b[j]:
            ab[i-j+8000]= 0
for i in range(B):
    if b[i] == '?':
        continue
    for j in range(C):
        if c[j] != '?' and b[i] != c[j]:
            bc[i-j+8000]= 0
for i in range(A):
    if a[i] == '?':
        continue
    for j in range(C):
        if c[j] != '?' and a[i] != c[j]:
            ac[i-j+8000]= 0
ans = 6000

for i in range(-4000, 4000):
    for j in range(-4000, 4000):
        if ab[i+8000] and bc[j-i+8000] and ac[j+8000]:
            L = min(0, min(i, j))
            R = max(A, max(B+i, C+j))
            ans = min(ans, R-L)
print(ans)
### BUGGY CODE ###

import sys
 
N=int(input())
#print(N)
A=input().split()
A_int = [int(s) for s in A]
#print(A_int)
ans=1
for i in range(N):
  ans=ans*A_int[i]

if(ans>10**18):
  ans=-1

print(ans)

### FIXED CODE ###

import sys
 
N=int(input())
#print(N)
A=input().split()
A_int = [int(s) for s in A]
#print(A_int)
if 0 in A_int:
  print(0)
  sys.exit()


ans=1
for i in range(N):
  ans=ans*A_int[i]
  if(ans>10**18):
    ans=-1
    break

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

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

d={}

for i,j in enumerate(A):
    d[i]=j

d=sorted(d.items(),key=lambda x:x[1],reverse=True)

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

c=0
for k,v in d:
    for i in range(c+1):
        dp[i+1][c-i]=max(dp[i+1][c-i],dp[i][c-i]+abs(v*(k-i)))
        dp[i][c-i+1]=max(dp[i][c-i+1],dp[i][c-i]+abs(v*(N-(c-i)-k-1)))
    c+=1

ans=0
for i in range(N):
    ans=max(ans,dp[i][N-i])

print(ans)

### FIXED CODE ###

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

d={}

for i,j in enumerate(A):
    d[i]=j

d=sorted(d.items(),key=lambda x:x[1],reverse=True)

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

c=0
for k,v in d:
    for i in range(c+1):
        dp[i+1][c-i]=max(dp[i+1][c-i],dp[i][c-i]+abs(v*(k-i)))
        dp[i][c-i+1]=max(dp[i][c-i+1],dp[i][c-i]+abs(v*(N-(c-i)-k-1)))
    c+=1

ans=0
for i in range(N):
    ans=max(ans,dp[i][N-i])

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

import io
import os

from collections import Counter, defaultdict, deque


from functools import lru_cache
import sys

sys.setrecursionlimit(10 ** 5)


def solve(N, A):
    @lru_cache(maxsize=None)
    def maxProfitAtEnd(i, money, stocks):
        if i == N - 1:
            # Sell all remaining
            return money + stocks * A[i]

        # no op
        best = maxProfitAtEnd(i + 1, money, stocks)
        # sell
        best = max(best, maxProfitAtEnd(i + 1, money + stocks * A[i], 0))
        # buy
        numStock = money // A[i]
        best = max(
            best, maxProfitAtEnd(i + 1, money - numStock * A[i], stocks + numStock)
        )

        return best

    return maxProfitAtEnd(0, 1000, 0)


if __name__ == "__main__":
    input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

    (N,) = [int(x) for x in input().split()]
    A = [int(x) for x in input().split()]
    ans = solve(N, A)
    print(ans)


### FIXED CODE ###

import io
import os

from collections import Counter, defaultdict, deque


from functools import lru_cache
import sys

sys.setrecursionlimit(10 ** 5)


def solve(N, A):
    @lru_cache(maxsize=None)
    def maxProfitAtEnd(i, money, stocks):
        if i == N - 1:
            # Sell all remaining
            return money + stocks * A[i]

        # no op
        best = maxProfitAtEnd(i + 1, money, stocks)
        # sell
        best = max(best, maxProfitAtEnd(i + 1, money + stocks * A[i], 0))
        # buy
        numStock = money // A[i]
        best = max(
            best, maxProfitAtEnd(i + 1, money - numStock * A[i], stocks + numStock)
        )

        return best

    return maxProfitAtEnd(0, 1000, 0)


def solve(N, A):
    money = 1000
    stock = 0
    for i in range(N - 1):
        if A[i] < A[i + 1]:
            # Buy on i
            numStock = money // A[i]
            money -= numStock * A[i]
            stock += numStock
            # Sell on i + 1
            money += stock * A[i + 1]
            stock = 0
    assert stock == 0
    return money


if __name__ == "__main__":
    input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

    (N,) = [int(x) for x in input().split()]
    A = [int(x) for x in input().split()]
    ans = solve(N, A)
    print(ans)
### BUGGY CODE ###

n, q = map(int, input().split())
s = input()
lr = [tuple(map(int, input().split())) for _ in range(q)]

for l, r in lr:
    count = 0
    for i in range(l-1, r-1):
        if s[i:i+2]=='AC':
            i = i+1
            count += 1
    print(count)


### FIXED CODE ###

N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
lr = [tuple(map(int, input().split())) for _ in range(Q)]
for i in range(N):
    t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for l, r in lr:
    print(t[r-1] - t[l-1])
### BUGGY CODE ###

import sys
import collections
n = int(sys.stdin.readline())
a = []
for _ in range(n):
  a.append(sys.stdin.readline().strip())
c = collections.Counter(a)
print(*sorted([i[0] for i in c.items() if i[1] == max(c.values())]))

### FIXED CODE ###

import sys
import collections
n = int(sys.stdin.readline())
a = []
for _ in range(n):
  a.append(sys.stdin.readline().strip())
c = collections.Counter(a)
maxc = max(c.values())
print(*sorted([i[0] for i in c.items() if i[1] == maxc]))
### BUGGY CODE ###

N = int(input())
li = list(map(int, input().split()))
a = []
b = 0
for i in li:
  a.append(i)
  if i < max(a):
    b = b + max(a) - i
print(b)

### FIXED CODE ###

N = int(input())
li = list(map(int, input().split()))
a = 0
b = 0
for i in li:
  if a < i:
    a = i
  if i < a:
    b = b + a - i
print(b)
### BUGGY CODE ###

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

ans = 0
for i in range(n):
    if P[i] == min(P[0:i+1]):
        ans += 1
        
print(ans)

### FIXED CODE ###

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

num = 2*10**5+1
ans = 0
for i in range(n):
    if P[i] <= num:
        num = P[i]
        ans += 1
        
print(ans)
### BUGGY CODE ###

import sys

#sys.stdin = open('input3.txt', 'r')

H, W , N = map(int, raw_input().split())
squares = []
results = [0 for _ in range(10)]
for _ in range(N):
	h, w = map(int, raw_input().split())
	for x in [(0, 0), (0, -1), (0, -2), (-1, 0), (-1, -1), (-1, -2), (-2, 0), (-2, -1), (-2, -2)]:
		nh, nw = h + x[0], w + x[1]
		if ((nh < 1) or (nw < 1) or (nh + 2 > H) or (nw + 2 > W)):
			pass
		else:
			squares.append((nh, nw))
squares.sort()

current = ()
count = 0
for s in squares:
	if s != current:
		results[count] = results[count] + 1
		current = s
		count = 1
	else:
		count = count + 1
results[count] = results[count] + 1


subtotal = 0
for x in range(1, 10, 1):
	subtotal += results[x]
results[0] = (H - 2) * (W - 2) - subtotal

for x in range(10):
	print str(results[x])


### FIXED CODE ###

import sys

#sys.stdin = open('input1.txt', 'r')

H, W , N = map(int, raw_input().split())
squares = {}
results = [0 for _ in range(10)]
for _ in range(N):
	h, w = map(int, raw_input().split())
	for x in [(0, 0), (0, -1), (0, -2), (-1, 0), (-1, -1), (-1, -2), (-2, 0), (-2, -1), (-2, -2)]:
		nh, nw = h + x[0], w + x[1]
		if ((nh < 1) or (nw < 1) or (nh + 2 > H) or (nw + 2 > W)):
			pass
		else:
			if (nh, nw) in squares:
				squares[(nh, nw)] += 1
			else:
				squares[(nh, nw)] = 1

for v in squares.values():
	results[v] += 1

results[0] = (H - 2) * (W - 2) - sum(results[1:])

for x in range(10):
	print str(results[x])
### BUGGY CODE ###

from scipy.sparse.csgraph import dijkstra
import sys

def input():
    return sys.stdin.readline().strip()

N = int(input())

graph = [[0 for i in range(N)] for j in range(N)]

for i in range(N-1):
    a,b,c = map(int,input().split())
    graph[a-1][b-1] = c
    graph[b-1][a-1] = c

dist = dijkstra(graph)

Q,K = map(int,input().split())
for i in range(Q):
    x,y = map(int,input().split())
    print(int(dist[x-1][K-1]+dist[K-1][y-1]))

### FIXED CODE ###

import heapq

"""
https://juppy.hatenablog.com/entry/2019/02/18/%E8%9F%BB%E6%9C%AC_python_%E3%83%97%E3%83%A9%E3%82%A4%E3%82%AA%E3%83%AA%E3%83%86%E3%82%A3%E3%82%AD%E3%83%A5%E3%83%BC%28heapq%29%E3%82%92%E7%94%A8%E3%81%84%E3%81%9F%E3%83%97%E3%83%AA%E3%83%A0%E6%B3%95
"""

def dijkstra_heap(s,edge):
    #始点sから各頂点への最短距離
    d = [10**10]*n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d
 
################################
N = int(input())
n = N
w = N
 
edge = tuple([] for i in range(n))
#edge[i] : iから出る道の[重み,行先]の配列
for i in range(w-1):
    a,b,c = map(int,input().split())
    edge[a-1].append([c,b-1])
    edge[b-1].append([c,a-1])


Q,K = map(int,input().split())
dist = dijkstra_heap(K-1,edge)
 
for i in range(Q):
    x,y = map(int,input().split())
    print(int(dist[x-1]+dist[y-1]))
### BUGGY CODE ###

import sys
imput=sys.stdin.readline
n,m=map(int,input().split())
l=[int(input()) for i in range(m)]
dp=[0]*(n+1)
dp[0]=1
if 1 not in l:
    dp[1]=1
else:dp[1]=0 
for i in range(2,n+1):
    if i in l:
        dp[i]=0
    else:
        dp[i]=pow(dp[i-1]+dp[i-2],1,10**9+7)
print(dp[-1]%(10**9+7))

### FIXED CODE ###

n,m=map(int,input().split())
a=[-1]
for i in range(m):
    s=int(input())
    a.append(s)  
a.append(n+1)
if 1 in a:
    a=a[1:]
if n-1 in a:
    a=a[:-1]
b=[]
for i in range(len(a)-1):
    b.append(a[i+1]-a[i]-2)
l=[1,1,2]
for i in range(3,n+1):
    l.append(l[i-2]+l[i-1])
ans=1
#print(a,b,l)
for i in range(len(b)):
    if b[i]<0:
        print(0)
        break
    else:
        ans*=l[b[i]]%1000000007
else:
    print(ans%1000000007)
### BUGGY CODE ###

n = int(input())
l = list(map(int, input().split()))
c = 1
for i in l:
  c *= i
if c <= 1000000000000000000:
  print(c)
else:
  print(-1)

### FIXED CODE ###

n = int(input())
l = list(map(int, input().split()))
l.sort()
c = 1
i = 0
while i < n:
  c *= l[i]
  i += 1
  if c > 1000000000000000000:
    break
if c <= 1000000000000000000:
  print(c)
else:
  print(-1)
### BUGGY CODE ###

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

### FIXED CODE ###

import sys
N = int(input())
A = list(map(int,input().split()))
ans = A[0]
if A.count(0)>0:
  print(0)
  sys.exit()
for i in range(1,N):
  ans = ans*A[i]
  if ans>10**18:
    print(-1)
    sys.exit()
print(ans)
### BUGGY CODE ###

L,R = map(int,input().split())

if L-R > 672:
    print(0)
else:
    minMod = 100000000
    for i in range(L,R):
        for j in range(i+1,R+1):
            if minMod > (i*j)%2019:
                minMod = (i*j)%2019
    print(minMod)


### FIXED CODE ###

L,R = map(int,input().split())

if R-L > 672:
    print(0)
else:
    minMod = 2019
    for i in range(L,R):
        for j in range(i+1,R+1):
            tmp = (i*j)%2019
            if tmp == 0:
                minMod = 0
                break
            minMod = min(tmp,minMod)
    print(minMod)