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

n,m=map(int,input().split(" "))
l_init,r_init=map(int,input().split(" "))
ans=range(l_init,r_init+1)
for i in range(m-1):
	l,r=map(int,input().split(" "))
	ans=list(set(ans)&set(range(l,r+1)))
if len(ans)>n:
	print(n)
else:
	print(len(ans))

### FIXED CODE ###

n,m=map(int,input().split(" "))
l_init,r_init=map(int,input().split(" "))
ans_l=l_init
ans_r=r_init
isPossible=True
for i in range(m-1):
	l,r=map(int,input().split(" "))
	isupdated=False
	next_ans_l=ans_l
	next_ans_r=ans_r
	if ans_l <= l and l <= ans_r:
		next_ans_l=l
		isupdated=True
	if ans_l <= r and r <= ans_r:
		next_ans_r=r
		isupdated=True
	if l <= ans_l and ans_r <= r:
		isupdated=True
	if not isupdated:
		isPossible=False
		break
	ans_l=next_ans_l
	ans_r=next_ans_r
ans=ans_r-ans_l
if isPossible:
	print(ans+1)
else:
	print(0)
### BUGGY CODE ###

N = int(input())
lsa = list(map(int,input().split()))
lsb = []
for i in range(N):
    if i % 2 == 0:
        lsb.append(lsa[i])
    else:
        lsb.insert(0,lsa[i])
    
if N%2 == 1:
    lsb.reverse() 
lsans = [str(i) for i in lsb]
print(' '.join(lsans))

### FIXED CODE ###

import collections
N = int(input())
lsa = list(map(str,input().split()))
lsb = collections.deque()
if N%2 == 0:
    for i in range(N):    
        if i % 2 == 0:
            lsb.append(lsa[i])
        else:
            lsb.appendleft(lsa[i])
if N%2 == 1:
    for i in range(N):
        if i % 2 == 1:
            lsb.append(lsa[i])
        else:
            lsb.appendleft(lsa[i])

print(' '.join(lsb))
### BUGGY CODE ###

S = input()
ret = 0
counter = {0: 1}
for i in range(len(S)):
    mod = int(S[-i:]) % 2019
    if mod in counter:
        counter[mod] += 1
    else:
        counter[mod] = 1

for k, v in counter.items():
    ret += v * (v - 1) // 2

print(ret)

### FIXED CODE ###

from collections import Counter

S = input()
mods = [0]
num, ten = 0, 1
for n in S[::-1]:
    num += int(n) * ten
    num %= 2019
    mods.append(num)
    ten *= 10
    ten %= 2019

counter = Counter(mods)
ret = 0
for v in counter.values():
    ret += v * (v - 1) // 2
print(ret)
### BUGGY CODE ###

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

mod=998244353

comb=1
pw=(M*pow(M-1,N-1,mod))%mod
ans=pw*comb

invmodk=[0]*(K+2)
invmodk[1]=1
invmodm=pow(M-1,mod-2,mod)
for k in range(2,K+1):
    invmodk[k]=invmodk[mod%k]*(mod-mod//k)%mod

for k in range(1,K+1):
    pw=(pw*invmodm)%mod
    comb*=(N-k)*invmodk[k]
    ans=(ans+pw*comb)%mod

print(ans)

### FIXED CODE ###

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

mod=998244353

com=1
ans=0

for i in range(K+1):
    ans+=M*com*pow(M-1,N-1-i,mod)
    ans%=mod
    com*=(N-1-i)*pow(i+1,mod-2,mod)
    com%=mod

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

import collections
import math
n = int(input())
l = list(map(int, input().split()))
ans = 0
for i in range(n):
  ans = 0
  temp = l.copy()
  temp.pop(i)
  c = collections.Counter(temp)
  for j in c.most_common():
    if j[1] > 1:
      ans += math.factorial(j[1]) // (math.factorial(j[1] - 2) * math.factorial(2))
  print(ans)

### FIXED CODE ###

n = int(input())
b = list(map(int, input().split()))
l = [0]*n
for i in range(n):
  l[b[i]-1] += 1
l2 = sum([i*(i-1)//2 for i in l])
for i in b:
  print(l2-(l[i-1]-1))
### BUGGY CODE ###

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

a_sorted = sorted(a)
divisible_list = [True] * n

for i in range(n-1):
    if not divisible_list[i]:
        continue
    for j in range(i+1, n):
        if a_sorted[j] == a_sorted[i]:
            divisible_list[i] = False
        if a_sorted[j] % a_sorted[i] == 0:
            divisible_list[j] = False
print(sum(divisible_list))

### FIXED CODE ###

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

a_sorted = sorted(a)
divisible_list = [0] * (max(a)+1)

for i in range(len(a)):
    for j in range(0, len(divisible_list), a[i]):
        divisible_list[j] += 1

ans = 0
for i in range(len(a)):
    if divisible_list[a[i]] == 1:
        ans+=1
print(ans)
### BUGGY CODE ###

N, M = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
for i in range(M):
    B, C = map(int, input().split())
    for n in range(N):
        if a[n] < C:
            a = a[:n] + [C for _ in range(B)] + a[n:]
            a = a[:N]
            break
print(sum(a))

### FIXED CODE ###

#import sys
#input = sys.stdin.readline
import numpy as np
N, M = map(int, input().split())
C = list(map(int, input().split()))
B = [1 for _ in range(N)]

for i in range(M):
    b, c = map(int, input().split())
    B.append(b)
    C.append(c)
C = np.array(C)
D = np.argsort(-C)
#print(B, C, D)
S = 0
n = 0
for i in D:
    #print(B[i], N-n, min(B[i], N-n))
    S += C[i] * (min(B[i], N-n))
    n += min(B[i], N-n)
    #print(S, n)
    if n == N:
        break
print(S)
### BUGGY CODE ###

import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N, K = map(int, input().split())
    MOD = 10 ** 9 + 7

    ans = 0
    memo = [0] * (K+1)
    def getLarge(x):
        if x == 1:
            return sum(memo)
        else:
            return sum(memo[x::x])

    for i in range(K, 0, -1):
        Ki = K // i
        c = Ki ** N - getLarge(i)
        memo[i] = c
        ans += i * c % MOD
    print(ans % MOD)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N, K = map(int, input().split())
    MOD = 10 ** 9 + 7

    ans = 0
    memo = [0] * (K+1)
    def getLarge(x):
        if x == 1:
            return sum(memo)
        else:
            return sum(memo[x::x])

    for i in range(K, 0, -1):
        Ki = K // i
        c = pow(Ki, N, MOD) - getLarge(i) % MOD
        memo[i] = c
        ans += i * c
        ans %= MOD
    print(ans % MOD)

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

#!/usr/bin/env python3

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    A_temp=[0]*N
    for k in range(K):
        for i in range(N):
            for j in range(max(0,i-A[i]),min(N,i+A[i]+1)):
                A_temp[j]+=1
        A=A_temp
        A_temp=[0]*N
    print(' '.join(map(str,A)))
    
if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    
    for k in range(K):
        A_temp=[0]*(N+1)
        for i in range(N):
            A_temp[max(0,i-A[i])]+=1
            if i+A[i]+1<=N-1:
                A_temp[i+A[i]+1]-=1
            
        A[0]=A_temp[0]
        for j in range(1,N):
            A_temp[j]+=A_temp[j-1]
            A[j]=A_temp[j]
        for ai in A:
            if ai != N:
                break
        else:
            break
                
    print(' '.join([str(a) for a in A]))
    
if __name__ == "__main__":
    main()
### BUGGY CODE ###

import sys 
sys.setrecursionlimit(10**6)

n,q = map(int,input().split())
dic = {i:[] for i in range(n)}
for i in range(n-1):  
  a,b = map(int,input().split())
  dic[a-1].append(b-1)
  dic[b-1].append(a-1)

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

def dfs(v,p):
  ans[v] = p + P[v]
  visited[v] = 1
  
  for nv in dic[v]:
    if visited[nv] == 0:
      dfs(nv,ans[v])
        
dfs(0,0)
print(*ans)

### FIXED CODE ###

from collections import deque

n,q = map(int,input().split())
cnt = [0]*(n+1)
g=[[] for _ in range(n+1)]

for _ in range(n-1):
  a,b=map(int,input().split())
  g[a].append(b)
  g[b].append(a)
  
for _ in range(q): 
  v,val=map(int,input().split())
  cnt[v]+=val    
  
q = deque()
q.append(1)
checked = [0]*(n+1) 
while q:
  v = q.pop()
  checked[v] = 1
  for vc in g[v]:
    if checked[vc] == 1:
      continue
    else:
      cnt[vc] += cnt[v]
      q.append(vc)
    
print(*cnt[1:])
### BUGGY CODE ###

#参考コードでTLSにならないことを確認する
N, K = map(int, input().split())
h = list(map(int, input().split()))
 
DP = [0]
for i in range(N-1):
    act = float("inf")
    for k in range(K):
        if i-k < 0 : continue
        act = min(DP[-1-k] + abs(h[i-k]-h[i+1]) , act)
    DP += [act]
 
print(DP[-1])

### FIXED CODE ###

import numpy as np
#https://yottagin.com/?p=1650

N,K=map(int,input().split())
h=list(map(int,input().split()))

#dp=[float("inf")]*N
#dp[0]=0
#dp=[0]
dp=np.zeros(N,dtype=int)
h=np.array(h)

for i in range(1,N):
  start=max(0,i-K)
  #start~i-1
  dp[i]=min(dp[start:i]+np.abs(h[i]-h[start:i]))
  #tmp=float("inf")
  #for k in range(1,K+1):
    #if i-k<0: break
    #dp[i]=min(dp[i],dp[i-k]+abs(h[i]-h[i-k]))
    #tmp=min(tmp,dp[i-k]+abs(h[i]-h[i-k]))
  #dp[i]=tmp
  #dp+=[tmp]

print(dp[N-1])
### BUGGY CODE ###

length = int(input())
targ = []
cnt = 0
mcnt = 1
for l in range(length):
    targ.append(int(input()))
m = 1
mlist = [1]
while length / 9 >= m:
    m = 3 * m + 1
    mcnt += 1
    mlist.append(m)
print(mcnt)
print(' '.join([str(n) for n in reversed(mlist)]))
while m >= 1:
    divided = length // m
    for inh in range(m,length):
        inlength = inh - m
        temp = targ[inh]
        while inlength >= 0 and temp < targ[inlength]:
            targ[inlength + m] = targ[inlength]
            cnt += 1
            inlength -= m
        targ[inlength + m] = temp
    m //= 3
print(cnt)
for l in range(length):
    print(targ[l])

### FIXED CODE ###

import math
length = int(input())
targ = []
cnt = 0
mcnt = 1
for l in range(length):
    targ.append(int(input()))
m = 1
mlist = [1]
while True:
    m = math.ceil(2.25 * m + 1)
    if length <= m:
        break
    mcnt += 1
    mlist.append(m)
print(mcnt)
print(' '.join([str(n) for n in reversed(mlist)]))
mlength = mcnt - 1
while mlength >= 0:
    m = mlist[mlength]
    divided = length // m
    for inh in range(m,length):
        inlength = inh - m
        temp = targ[inh]
        while inlength >= 0 and temp < targ[inlength]:
            targ[inlength + m] = targ[inlength]
            cnt += 1
            inlength -= m
        targ[inlength + m] = temp
    mlength -= 1
print(cnt)
for l in range(length):
    print(targ[l])
### BUGGY CODE ###

MOD = 1000000007

n = int(input())
str_ary = input().split()
ary = [int(c) for c in str_ary]

result = 0
# for diff in range(n - 1):
#   for i in range(n - diff - 1):
#     # print(i, i + diff + 1)
#     sum += ary[i] * ary[i + diff + 1]
for i in range(n):
  sum = 0
  for j in range(n - i - 1):
    # print(i, j + i + 1)
    sum += ary[j + i + 1]
  result += ary[i] * sum

print(result % MOD)

### FIXED CODE ###

MOD = 1000000007

n = int(input())
str_ary = input().split()
ary = [int(c) for c in str_ary]
# ary = []
# queue = [0 for i in range(n)]
# for i int range(n):
#   num = int(str_ary[i])
#   ary.append(num)
#   for j int range(i):
#     pre_queue = []
#     queue.append(pre_queue)

result = 0
sum = sum(ary[i] for i in range(n))
# for diff in range(1, n):
#   for i in range(n - diff):
#     # print(diff, i, i + diff)
#     sum += ary[i] * ary[i + diff] % MOD
for i in range(n):
  sum -= ary[i]
  result += ary[i] * sum

print(result % MOD)
### BUGGY CODE ###

N = int(input())
As = list(map(int, input().split()))
res = 0
for l in range(N):
    val = As[l]
    cnt = 1
    r = l+1
    while (r < N and val^As[r] == val+As[r]):
        # print(l,r,val)
        val += As[r]
        cnt += 1
        r += 1
    res += cnt
    # print(l,cnt)
print(res)



### FIXED CODE ###

"""
多分またバグらせる
"""
# 尺取

N = int(input())
As = list(map(int, input().split()))
res = 0
l,r = 0, 0
val = As[l]
for l in range(N):
    cnt = 0
    # 区間が1のときは確定でOKなので+1する
    if l == r:
        r += 1
        val = As[l]
    # 差分が1以上(実質、区間が2つ以上存在するとき)
    elif r-(l-1) > 1:
        val -= As[l-1]
    # 条件を満たすうちは尺を伸ばす
    # print("be","l",l,"r",r,"val",val)
    while (r < N and val^As[r] == val+As[r]):
        val += As[r]
        r += 1
    # print("af","l",l,"r",r,"val",val)
    # 条件が終了したら差分を加える
    res += (r-l)
print(res)
### BUGGY CODE ###

def main():
    n, k = map(int, input().split())
    h = tuple(map(int, input().split()))
    INF = 10 ** 9
    dp = [INF] * n
    dp[0] = 0
    for i in range(n):
        for j in range(1, k + 1):
            i_j = i + j
            if i_j < n:
                dp[i_j] = min(dp[i_j], dp[i] + abs(h[i] - h[i_j]))
    print(dp[-1])


if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    n, k = map(int, input().split())
    h = tuple(map(int, input().split()))
    INF = 10 ** 9
    dp = [INF] * n
    dp[0] = 0
    for i in range(n):
        for j in range(1, k + 1):
            i_j = i + j
            if i_j < n:
                x = dp[i] + abs(h[i] - h[i_j])
                if dp[i_j] > x:
                    dp[i_j] = x
    print(dp[-1])


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

N = int(input())
V = []
for _ in range(N-1):
    u, v, w = map(int, input().split())
    V.append((u,v,w))

edges = V[:]

def warshall_floyd(d, n):
    # d: グラフ二次元リスト
    # n: 頂点数 (0始まり)
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

graph = [[float("inf") for i in range(N)] for i in range(N)] 
for x,y,z in edges:
    graph[x-1][y-1] = z
    graph[y-1][x-1] = z
for i in range(N):
    graph[i][i] = 0 #自身のところに行くコストは０
shortest = warshall_floyd(graph, N)

color = [1] * N
color[0] = 0

for i, sub in enumerate(shortest):
    for j, l in enumerate(sub):
        if l % 2 == 0:
            color[j] = color[i]
for c in color:
    print(c)

### FIXED CODE ###

N = int(input())
V = []
for _ in range(N-1):
    u, v, w = map(int, input().split())
    V.append((u,v,w))
    
edges = V[:]

from heapq import heappush, heappop

def dijkstra(graph, start):
    A = [None] * (N)
    queue = [(0, start)]
    while queue:
        path_len, v = heappop(queue)
        if A[v] is None: # v is unvisited
            A[v] = path_len
            for w, edge_len in graph[v].items():
                if A[w] is None:
                    heappush(queue, (path_len + edge_len, w))

    # to give same result as original, assign zero distance to unreachable vertices             
    return [0 if x is None else x for x in A]



# 無効グラフなので双方向にする
graph = {}
for a,b,c in edges:
    a = a-1
    b = b-1
    if not a in graph:
        graph[a] = {}
    if not b in graph:
        graph[b] = {}
    graph[a][b] = c
    graph[b][a] = c
    
    
shortest = dijkstra(graph, 0)

for s in shortest:
    print(s % 2)
### BUGGY CODE ###

s = str(input())
n = len(s)
s = s[::-1]
x, tot = 1, 0
m = 2019
ans = 0
cnt = [int() for _ in range(m)]
for i in range(n):
    cnt[tot] += 1
    tot += (int(s[i])) * x
    tot %= m
    ans += cnt[tot]
    x = x * 10 
print(ans)


### FIXED CODE ###

s = str(input())
n = len(s)
s = s[::-1]
x, tot = 1, 0
m = 2019
ans = 0
cnt = [int() for _ in range(m)]
for i in range(n):
    cnt[tot] += 1
    tot += (int(s[i])) * x
    tot %= m
    ans += cnt[tot]
    x = x * 10 % m
print(ans)
### BUGGY CODE ###

if __name__=='__main__':
    n,k,*h=map(int,open(0).read().split())
    dp=[0]+[10**18]*~-n
    for i in range(1,n):
        for j in range(k):
            if i-k+j<0:continue
            dp[i]=min(dp[i],dp[i-k+j]+abs(h[i]-h[i-k+j]))
    print(dp[-1])

### FIXED CODE ###

n,k,*h=map(int,open(0).read().split())
dp=[0]+[10**18]*~-n
for i in range(1,n):
    for j in range(k):
        if i-k+j<0:continue
        dp[i]=min(dp[i],dp[i-k+j]+abs(h[i]-h[i-k+j]))
print(dp[-1])
### BUGGY CODE ###

N = int(input())
S = str(input())
ans = 0

for j in range(1, N+1):
    if S[-j] == '#':
        j += 1
    else:
        break

if j == 1:
    last = 0
else:
    last = j-1
i = 0
while i < N:
    if S[i:i+2] == '#.':
        ans += 1
        new_S = S[:i+1] + '#' + S[i+2:]
        S = new_S
    i += 1

print(min(ans, N-ans-last))

### FIXED CODE ###

N = int(input())
S = str(input())

ans = [S.count('.')]
for i in range(N):
    temp = ans[-1]
    if S[i] == '#':
        temp += 1
    else:
        temp -= 1
    ans.append(temp)
    
print(min(ans))
### BUGGY CODE ###

import sys

N, H = [int(x) for x in sys.stdin.readline().strip().split()]
A = []
B = []
for i in range(N):
    a, b = [int(x) for x in sys.stdin.readline().strip().split()]
    A.append(a)
    B.append(b)

r = 1000000000000
for i in range(N):
    p = A[i]
    qs = [B[i] for i in range(N) if B[i] > p]
    rr = ((H - sum(qs) + (p - 1)) // p) + len(qs)
    r = min(r, rr)

print(r)


### FIXED CODE ###

import sys

N, H = [int(x) for x in sys.stdin.readline().strip().split()]
AB = [tuple(int(x) for x in sys.stdin.readline().strip().split()) for i in range(N)]
AB.sort(key=lambda x:(-x[0],x[1]))

p = AB[0][0]
qs = [AB[j][1] for j in range(N) if AB[j][1] > p]
qs.sort(key=lambda x:-x)
r = 0
for i in range(len(qs)):
    if H <= 0:
        break
    H -= qs[i]
    r += 1

if H > 0:
    r = r + (H + (p - 1)) // p

print(r)
### BUGGY CODE ###

list1 = list(map(int, input().split()))
a = list1[0]
b = list1[1]
c = list1[2]
k = list1[3]

pointH =a
pointM =b
pointL =c

if a ==b and b ==c:
    print(0)
else:
    index =0
    while index<k:
        list2 = [pointM+pointL,pointL+pointH,pointH+pointM]
        pointH = list2[0]
        pointM = list2[1]
        pointL = list2[2]
        index+=1

    if pointH-pointM>10**18:
        print("Unfair")
    else:
        print(pointH-pointM)

### FIXED CODE ###

list1 = list(map(int, input().split()))
a = list1[0]
b = list1[1]
c = list1[2]
k = list1[3]


if k%2 ==0:
    ans = a-b
else:
    ans = b-a

if ans>10**18:
    print("Unfair")
else:
    print(ans)
### BUGGY CODE ###

n = int(raw_input())
a = map(int, raw_input().split())

chk = {}
def make_divisors(k):
    divisors = []
    for i in range(1, int(k**0.5)+1):
        if k % i == 0:
            #divisors.append(i)
            if i in chk:
                chk[i] += 1
            else:
                chk[i] = 1
            if i != k // i:
                #divisors.append(n//i)
                key = int(k//i)
                if key in chk:
                    chk[key] += 1
                else:
                    chk[key] = 1

    # divisors.sort()
    return divisors

if n == 2:
    print max(a[0],a[1])
else:
    for i in range(2):
        make_divisors(a[i])
    cnt = 1
    for i in reversed(range(2,len(a))):
        k = a[i]
        del_list = []
        for j in chk:
            if k % j == 0:
                chk[j] += 1
            if chk[j] < cnt+1:
                del_list.append(j)
        for j in del_list:
            del chk[j]
        cnt += 1

    answer = max(chk.keys())
    print answer

### FIXED CODE ###

n = int(raw_input())
a = raw_input().split()

cnt = 0
for i in a:
    a[cnt] = int(i)
    cnt += 1

chk = {}
chk2 = {}
def make_divisors(k):
    divisors = []
    for i in range(1, int(k**0.5)+1):
        if k % i == 0:
            if i in chk:
                chk[i] += 1
            else:
                chk[i] = 1
            if i != k // i:
                key = int(k//i)
                if key in chk:
                    chk[key] += 1
                else:
                    chk[key] = 1
    return divisors

for i in range(2):
    make_divisors(a[i])
cnt = 1
for i in range(2,len(a)):
    k = a[i]
    if k not in chk2:
        chk2[k] = 1
    else:
        if chk2[k] == 1:
            chk2[k] += 1
        elif chk2[k] > 1:
            continue
    del_list = []
    for j in chk:
        if k % j == 0:
            chk[j] += 1
        if chk[j] < cnt+1:
            del_list.append(j)
    for j in del_list:
        del chk[j]
    cnt += 1

answer = 0
for i in chk:
    if int(chk[i]) >= chk[1] - 1 and i > answer:
        answer = i
print answer
### BUGGY CODE ###

N=int(input())
lst=input().split()
cnt=0
for i in lst:
    for j in lst:
        cnt+=i==j
    s=(cnt-N)//2+1
for i in lst:
    print(s-lst.count(i))

### FIXED CODE ###

import collections
N=int(input())
lst=input().split()
s=0
dic=collections.Counter(lst)
for i in dic.values():
    s+=(i*i-i)//2
for i in lst:
    print(s+1-dic[i])
### BUGGY CODE ###

N = int(input())
HPs = list(map(int,input().split()))
while(True):
    min_hp = min(HPs)
    max_hp = max(HPs)
    HPs[HPs.index(max_hp)] = max_hp % min_hp
    try:
        while(True):
            HPs.remove(0)
            if len(HPs)==1:
                break
    except:
        continue
    if len(HPs) == 1:
        break
print(HPs[0])


### FIXED CODE ###

from fractions import gcd
N = int(input())
HPs = list(map(int,input().split()))
ans = HPs[0]
for i in HPs:
    ans = gcd(ans,i)
print(ans)
### BUGGY CODE ###

from copy import deepcopy
import sys
sys.setrecursionlimit(10 ** 6)


def main():
    h, w = list(map(int, input().split()))
    matrix = []
    for _ in range(h):
        matrix.append([c for c in input()])

    adj = [(0, 1), (0, -1), (1, 0), (-1, 0)]
    depth = [[0 for _ in range(w)] for _ in range(h)]

    def calcdepth(i, j, current, m):
        checked = deepcopy(m)
        checked[i][j] = 'S'

        # for line in checked:
        #     print(line)
        # print('-' * 20)

        queue = [(i, j, 0)]
        while (len(queue) > 0):
            y, x, dep = queue.pop(0)
            if m[y][x] == '#':
                # print('hit!', dep)
                return dep

            for dy, dx in adj:
                next = (y + dy, x + dx, dep + 1)

                if -1 < next[0] < h and -1 < next[1] < w:
                    pt = checked[next[0]][next[1]]
                    if pt == '.':
                        checked[next[0]][next[1]] = 'X'
                        queue.append(next)
                    if pt == '#':
                        return dep + 1

        return 0

    for i in range(h):
        for j in range(w):
            depth[i][j] = calcdepth(i, j, 0, matrix)

    # for l in depth:
    #     print(l)

    print(max([depth[i][j] for i in range(h) for j in range(w)]))


main()


### FIXED CODE ###

import numpy

def main():
    h, w = map(int, input().split())
    max_value = h + w
    gridmap = []

    for y in range(h):
        gridmap.append([0 if v == '#' else max_value for v in input().strip()])

    values = numpy.array(gridmap)

    for x in range(w - 1):
        values[:, x + 1] = numpy.minimum(values[:, x] + 1, values[:, x + 1])

    for x in range(w - 1, 0, -1):
        values[:, x - 1] = numpy.minimum(values[:, x] + 1, values[:, x - 1])

    for y in range(h - 1):
        values[y + 1, :] = numpy.minimum(values[y, :] + 1, values[y + 1, :])

    for y in range(h - 1, 0, -1):
        values[y - 1, :] = numpy.minimum(values[y, :] + 1, values[y - 1, :])

    print(numpy.max(values))


main()
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
ans = 1
for i in range(0, n):
    ans *= a[i]
if ans <= 1_000_000_000_000_000_000:
    print(ans)
else:
    print(-1)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
ans = 1
a.sort()
for i in range(0, n):
    if ans * a[i] <= 1_000_000_000_000_000_000:
        ans *= a[i]
    else:
        ans = 1_000_000_000_000_000_001
        break
if ans <= 1_000_000_000_000_000_000:
    print(ans)
else:
    print(-1)