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

n,m,Q = map(int,input().split())
LR = []
pon = []
for _ in range(m):
    LR.append(list(map(int,input().split())))
for _ in range(Q):
    p,q = map(int,input().split())
    ans = 0
    for i in range(m):
        if p<=LR[i][0] and LR[i][1] <= q:
            ans += 1
    pon.append(ans)
for i in range(Q):
    print(pon[i])

### FIXED CODE ###

n, m, Q = map(int, input().split())
data = [[0]*(n+2) for i in range(n+2)]
for i in range(m):
    l, r = map(int, input().split())
    data[l][r] += 1

for i in range(n+2):
    for j in range(n+1):
        data[i][j+1] += data[i][j]

for i in range(n+1, -1, -1):
    for j in range(n+2):
        data[i-1][j] += data[i][j]

for i in range(Q):
    p, q = map(int, input().split())
    print(data[p][q])
### BUGGY CODE ###

import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))
n, k = map(int, input().split())
a = list(map(int, input().split()))
rui = [1]
t = 1
for i in range(n):
    t *= a[i]
    if i < k:
        rui += [t]
    else:
        rui += [t // rui[i - k + 1]]

#print(rui)

for i in range(n+1):
    if i < k+1: continue
    if rui[i] > rui[i - 1]:
        print('Yes')
    else:
        print('No')


### FIXED CODE ###

import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))
n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(k, n):
    if a[i] > a[i - k]:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

#CODE FESTIVAL 2016 Final-C
"""
グラフが連結であるかどうかを判定せよ？
距離が2以下になっているか判定せよかと思ったが、つながってればいいっぽい？
dfsで全部回れば良い
"""
import sys
from collections import deque
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
n,m = map(int,readline().split())
g = [[] for i in range(m)] #その言語を誰が使えるか
h = [] #誰がどの言語を使えるか
for i in range(n):
    lst1 = list(map(int,readline().split()))
    lst1 = lst1[1:]
    for j in lst1:
        g[j-1].append(i)
    h.append(lst1)


check = [0]*n
root = 0
check[root] = 1
deq = deque([root])
while deq:
    fr = deq.pop()
    for i in h[fr]:
        for j in g[i-1]:
            if check[j]:
                continue
            deq.append(j)
            check[j] = 1


if all(i==1 for i in check):
    print("YES")
else:
    print("NO")

### FIXED CODE ###

#CODE FESTIVAL 2016 Final-C
"""
グラフが連結であるかどうかを判定せよ？
距離が2以下になっているか判定せよかと思ったが、つながってればいいっぽい？
dfsで全部回れば良い
"""
import sys
from collections import deque
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
n,m = map(int,readline().split())
g = [[] for i in range(m)] #その言語を誰が使えるか
h = [] #誰がどの言語を使えるか
for i in range(n):
    lst1 = list(map(int,readline().split()))
    lst1 = lst1[1:]
    for j in lst1:
        g[j-1].append(i)
    h.append(lst1)


check = [0]*n
language = [0]*m
root = 0
check[root] = 1
deq = deque([root])
while deq:
    fr = deq.pop()
    for i in h[fr]:
        if language[i-1]:
            continue
        language[i-1] = 1
        for j in g[i-1]:
            if check[j]:
                continue
            deq.append(j)
            check[j] = 1


if all(i==1 for i in check):
    print("YES")
else:
    print("NO")
### BUGGY CODE ###

m=10**9+7
def f(r,c,s=1):
 for i in range(c):s=s*(r+c-i)*pow(i+1,m-2,m)%m
 return s
a,b,c,d=map(int,input().split())
print((f(a,b)-f(c+1,b)-f(a,d+1)+f(c+1,d+1))%m)

### FIXED CODE ###

m=10**9+7
def f(r,c):
 s=t=1
 for i in range(c):s=s*(r+c-i)%m;t=t*-~i%m
 return s*pow(t,m-2,m)%m
a,b,c,d=map(int,input().split())
print((f(a,b)-f(c+1,b)-f(a,d+1)+f(c+1,d+1))%m)
### BUGGY CODE ###

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

dp = [[[False] * 1000 for _ in range(4)] for _ in range(N + 1)]
dp[0][0][0] = True

for i in range(N):
    for j in range(4):
        for k in range(1000):
            if not dp[i][j][k]:
                continue
                
            # Not choose S[i]
            dp[i + 1][j][k] = True
            
            # Choose S[i]
            if j < 3:
                dp[i + 1][j + 1][k * 10 + int(S[i])] = True
            
print(sum(dp[-1][-1]))


### FIXED CODE ###

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

ctr = [0] * 1000
ans = 0
for i in range(1000):
    v1 = i // 100
    v2 = i // 10 - v1 * 10
    v3 = i - v1 * 100 - v2 * 10
    
    p1 = S.find(str(v1))
    if p1 < 0:
        continue
        
    p2 = S[p1+1:].find(str(v2))
    if p2 < 0:
        continue
        
    p3 = S[p1+p2+2:].find(str(v3))
    ans += int(p3 >= 0)
    
print(ans)
### BUGGY CODE ###

def calc_dist(lst):
    s = 0
    lst.insert(0, 0)
    lst.append(0)
    for i in range(len(lst) - 1):
        s += abs(lst[i] - lst[i+1])
    return s

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

for i in range(N):
    lst = A.copy()
    lst.pop(i)
    s = calc_dist(lst)
    print(s)


### FIXED CODE ###

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

sum = 0

for i in range(len(A) - 1):
    sum += abs(A[i+1] - A[i])

for i in range(N):
    temp = sum
    temp -= (abs(A[i+1] - A[i]) + abs(A[i+2] - A[i+1]))
    temp += abs(A[i+2] - A[i])
    print(temp)
### BUGGY CODE ###

N, T = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]
AB.sort(key = lambda x: x[0])

DP = [[0] * T for _ in range(N-1)]

for i in range(N-1):
	for j in range(T):
		if i == 0:
			if j >= AB[0][0]:
				DP[i][j] = AB[0][1]
		else:
			if j >= AB[i][0]:
				DP[i][j] = max(DP[i-1][j], DP[i-1][j-AB[i][0]] + AB[i][1])
			else:
				DP[i][j] = DP[i-1][j]

ans = 0
tmp = 0

for i in reversed(range(N-1)):
	tmp = max(tmp, AB[i+1][1])
	ans = max(ans, DP[i][T-1] + tmp)

print(ans)

### FIXED CODE ###

N, T = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]
AB.sort(key = lambda x: x[0])

DP = [[0] * T for _ in range(N-1)]

for i in range(N-1):
	for j in range(T):
		if i == 0:
			if j >= AB[0][0]:
				DP[i][j] = AB[0][1]
		else:
			if j >= AB[i][0]:
				DP[i][j] = max(DP[i-1][j], DP[i-1][j-AB[i][0]] + AB[i][1])
			else:
				DP[i][j] = DP[i-1][j]

ans = 0
tmp = 0

for i in reversed(range(N-1)):
	tmp = max(tmp, AB[i+1][1])
	ans = max(ans, DP[i][T-1] + tmp)

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

N = int(input())

start = 0
end = N

print(0)
s0 = input()
if s0 == 'Vacant':
    exit()

ni = (start+end)//2
print(ni, flush=True)
s = input()

while s != 'Vacant':
    if not((s == s0) ^ (s % 2 == s0 % 2)):
        start = ni
    else:
        end = ni

    s0 = s

    ni = (start+end)//2
    print(ni, flush=True)
    s = input()


### FIXED CODE ###

N = int(input())


def ask(i):
    print(i, flush=True)
    resp = input()
    if resp == 'Vacant':
        exit()
    return resp


def test(l, r, l_resp, r_resp):
    if l % 2 == r % 2:
        return l_resp == r_resp
    else:
        return l_resp != r_resp


resp = ask(0)

l = 0
r = N
l_resp = resp
r_resp = resp

for _ in range(19):
    m = (l+r)//2
    m_resp = ask(m)
    if test(l, m, l_resp, m_resp):
        l, l_resp = m, m_resp
    else:
        r, r_resp = m, m_resp
### BUGGY CODE ###

K, S = map(int,input().split())
n = 0

for i in range(K+1):
  for j in range(K+1):
    for k in range(K+1):
      if i + j + k == S:
        
        n += 1
print(n)

### FIXED CODE ###

K, S = map(int,input().split())
n = 0

for i in range(K+1):
  for j in range(K+1):
    a = S-i-j
    if 0 <= a <= K:
      n+=1
print(n)
### BUGGY CODE ###

import sys
from sys import stdin
def I():
    return stdin.readline().rstrip()
def MI():
    return map(int,stdin.readline().rstrip().split())
def LI():
    return list(map(int,stdin.readline().rstrip().split()))
#main part
from collections import deque
H,W=MI()
route=[list(I()) for _ in range(H)]
d=deque()
for h in range(H):
    for w in range(W):
        if route[h][w]=='#':
            d.append([h,w])
cnt=0
while d:
    l=list(d)
    d.clear()
    for Y,X in l:
        for y,x in [[Y-1,X],[Y+1,X],[Y,X-1],[Y,X+1]]:
            if 0<=y<H and 0<=x<W:
                if route[y][x]=='.':
                    route[y][x]='#'
                    d.append([y,x])
    cnt+=1
print(cnt-1)

### FIXED CODE ###

import sys
from sys import stdin
def I():
    return stdin.readline().rstrip()
def MI():
    return map(int,stdin.readline().rstrip().split())
def LI():
    return list(map(int,stdin.readline().rstrip().split()))
#main part
from collections import deque
H,W=MI()
route=[list(I()) for _ in range(H)]
d=deque()
for h in range(H):
    for w in range(W):
        if route[h][w]=='#':
            d.append([h,w])
cnt=0
while d:
    l=list(d)
    d.clear()
    for Y,X in l:
        for y,x in [[Y-1,X],[Y+1,X],[Y,X-1],[Y,X+1]]:
            if 0<=y<H and 0<=x<W:
                if route[y][x]=='.':
                    route[y][x]='#'
                    d.append([y,x])
    cnt+=1
print(cnt-1)
### BUGGY CODE ###

s = input()
t = input()

S = [s[i] for i in range(len(s))]
T = [t[i] for i in range(len(t))]

for i in range(len(S)):
    S_ch = [j for j, x in enumerate(S) if x == S[i]]
    T_ch = [j for j, x in enumerate(T) if x == T[i]]
    if S_ch != T_ch:
        print('No')
        exit()

print('Yes')


### FIXED CODE ###

S = input()
T = input()

string = ''

for i in range(len(S)):
    if S[i] not in string:
        S_ch = [j for j, x in enumerate(S) if x == S[i]]
        T_ch = [j for j, x in enumerate(T) if x == T[i]]
        string += S[i]
        if S_ch != T_ch:
            print('No')
            exit()

print('Yes')
### BUGGY CODE ###

import numpy as np
import math

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

min = 2
max = 2

for i in reversed(a):
    k = i
    while(min > k):
        k += i
    if(k <= max):
        min = math.ceil(min / i) * i
        max = math.floor(max / i) * i + i - 1
    else:
        print(-1)
        exit()

print("%d %d" %(min, max))

### FIXED CODE ###

import numpy as np
import math

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

min = 2
max = 2

for i in reversed(a):
    min = math.ceil(min / i) * i
    max = math.floor(max / i) * i + i - 1
    if(min > max):
        print(-1)
        exit()

print("%d %d" %(min, max))
### BUGGY CODE ###

n=int(input())
s=input()
ans=n
for i in range(0,n+1):
    cw=s[:i].count('#')
    cb=s[i:].count('.')
    if ans>=cw+cb:
        ans=cw+cb
print(ans)

### FIXED CODE ###

n=int(input())
s=input()
w = s.count('.')
b = 0
ans=w+b
for i in s:
    if i=='#':
        b+=1
    else:
        w-=1
    if ans>=b+w:
        ans=b+w
print(ans)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
a.sort()
c = 0
for i in range(n):
    c = a.count(i+1)
    del a[:c]
    print(c)

### FIXED CODE ###

import collections

n = int(input())
a = list(map(int, input().split()))
l = collections.Counter(a)
for i in range(n):
    print(l[i+1])
### BUGGY CODE ###

mod = int(1e9+7)

fac = [1]

def add(a, b):
    c = a + b
    if c >= mod:
        c -= mod
    return c

def subtract(a, b):
    return (a - b) % mod

def mul(a, b):
    return (a * b) % mod

def my_pow(a, b):
    if b == 0:
        return 1
    if b % 2 == 1:
        return mul(a, my_pow(a, b-1))
    else:
        temp = my_pow(a, b/2)
        return temp * temp
    
def my_inv(a):
    return my_pow(a, mod-2)

def nCk(n, k, fac):
    if k > n:
        return 0
    #print(fac[n])
    #print(my_inv(mul(fac[n-k], fac[k])))
    return mul(fac[n], my_inv(mul(fac[n-k], fac[k])))

def main():
    n, k = [int(x) for x in raw_input().split()]
    
    a = [int(x) for x in raw_input().split()]
    
    fac = [0 for _ in range(2*n+1)]
    
    fac[0] = 1
    
    for i in range(1, 2*n+1):
        fac[i] = fac[i-1] * i
    
    a.sort()
    
    ans = 0
    
    for i in range(n-1):
        #print(a[i])
        diff = subtract(a[i+1], a[i])
        ways = nCk(n, k, fac)
        #print(ways)
        ways = subtract(ways, nCk(i+1, k, fac))
        ways = subtract(ways, nCk(n-i-1, k, fac))
        ans = add(ans, mul(diff, ways))
    
    print(ans)
    

main()

### FIXED CODE ###

mod = int(1e9+7)

fac = [1]

def add(a, b):
    c = a + b
    if c >= mod:
        c -= mod
    return c

def subtract(a, b):
    return (a - b) % mod

def mul(a, b):
    return (a * b) % mod

def my_pow(a, b):
    if b == 0:
        return 1
    if b % 2 == 1:
        return mul(a, my_pow(a, b-1))
    else:
        temp = my_pow(a, b/2)
        return temp * temp
    
def my_inv(a):
    return my_pow(a, mod-2)

def nCk(n, k, fac):
    if k > n:
        return 0
    #print(fac[n])
    #print(my_inv(mul(fac[n-k], fac[k])))
    return mul(fac[n], my_inv(mul(fac[n-k], fac[k])))

def main():
    n, k = [int(x) for x in raw_input().split()]
    
    a = [int(x) for x in raw_input().split()]
    
    fac = [0] * (n+5)
    
    #print(fac)
    
    fac[0] = 1
    
    for i in range(1, n+5):
        fac[i] = mul(fac[i-1], i)
    
    a.sort()
    
    ans = 0
    
    for i in range(n-1):
        #print(a[i])
        diff = subtract(a[i+1], a[i])
        ways = nCk(n, k, fac)
        #print(ways)
        ways = subtract(ways, nCk(i+1, k, fac))
        ways = subtract(ways, nCk(n-i-1, k, fac))
        ans = add(ans, mul(diff, ways))
    
    print(ans)
    

main()
### BUGGY CODE ###

from math import log2
from bisect import bisect_left


def getComp(n):
    return (1 << (1 + int(log2(n)))) - n


N = int(input())
A = [int(s) for s in input().split()]
A.sort()
avail = [True for _ in range(len(A))]

count = 0
for i in range(len(A) - 1, -1, -1):
    if not avail[i]:
        continue
    comp = getComp(A[i])
    j = bisect_left(A, comp)
    while True:
        if A[j] != comp:
            break
        if i == j or not avail[j]:
            j += 1
            continue
        avail[i] = False
        avail[j] = False
        count += 1
        break

print(count)


### FIXED CODE ###

# from math import log2
from math import log
from bisect import bisect_left


def log2(x):
    return log(x, 2)


def getComp(n):
    return (1 << (1 + int(log2(n)))) - n


N = int(input())
A = [int(s) for s in input().split()]
A.sort()
B = []
C = []
i = 0
while i < len(A):
    j = i
    count = 1
    while i+1 < len(A) and A[j] == A[i+1]:
        count += 1
        i += 1
    B.append(A[j])
    C.append(count)
    i += 1

count = 0
i = len(B) - 1
while i >= 0:
    comp = getComp(B[i])
    j = bisect_left(B, comp)
    if i == j and C[i] < 2:
        i -= 1
        continue
    if B[j] != comp:
        i -= 1
        continue
    if not C[i] or not C[j]:
        i -= 1
        continue
    C[i] -= 1
    C[j] -= 1
    count += 1

print(count)
### BUGGY CODE ###

import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

import math

k = ni()
ans = 0

for i in range(1,k+1):
    for j in range(1,k+1):
        for p in range(1,k+1):
            a = math.gcd(i,j)
            ans += math.gcd(a,p)

print(ans)

### FIXED CODE ###

import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

import math

k = ni()
ans = 0

for i in range(1,k+1):
    for j in range(1,k+1):
        for p in range(1,k+1):
            a = math.gcd(i,j)
            ans += math.gcd(a,p)

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

n,m = map(int , raw_input().split())
x = map(int, raw_input().split())
y = map(int, raw_input().split())

sum = 0

for i in range(n):
    for j in range(n):
            if i>j:
                for p in range(m):
                    for q in range(m):
                            if p > q:
                                sum += (x[i]-x[j])*(y[p]-y[q])
print sum % (10**9+7)

### FIXED CODE ###

import numpy as np
n,m = map(int , raw_input().split())
x = map(int, raw_input().split())
y = map(int, raw_input().split())

sum_x = 0
sum_y = 0

for i in range(n):
    sum_x += i*x[i]-(n-i-1)*x[i]
for i in range(m):
    sum_y += i*y[i]-(m-i-1)*y[i]
print (sum_x*sum_y) % (10**9+7)
### BUGGY CODE ###

# 初期入力
import sys
from collections import defaultdict
input = sys.stdin.readline  #文字列では使わない
H,W,M = map(int, input().split())

bom_H =defaultdict(int)
bom_W =defaultdict(int)
posision =set()
for i in range(M):
    h,w = map(int, input().split())
    bom_H[h] +=1
    bom_W[w] +=1
    posision.add((h,w))
indx_H = [k for k,v in bom_H.items() if v == max(bom_H.values())]
indx_W = [k for k,v in bom_W.items() if v == max(bom_W.values())]
set_max_H = set(indx_H)
set_max_W = set(indx_W)
temp_H =max(bom_H.values())
temp_W =max(bom_W.values())

flag =False
for h in set_max_H:
    for w in set_max_W:
        if (h,w) not in posision:
            flag =True
            break
    if flag==True:
        break

if flag ==True:
    print(temp_H +temp_W )
else:
    print(temp_H +temp_W -1)

### FIXED CODE ###

import sys


H, W, M = map(int, input().split())
bomb = [tuple(map(lambda x: int(x) - 1, s.split())) for s in sys.stdin.readlines()]
X = [0] * H  # X:各行の爆破対象の個数
Y = [0] * W  # Y:各列の爆破対象の個数
for h, w in bomb:
    X[h] += 1
    Y[w] += 1
maxX = max(X)
maxY = max(Y)

R = [h for h, x in enumerate(X) if x == maxX]  # R:爆破対象の数が最大となる行の番号
C = [w for w, y in enumerate(Y) if y == maxY]  # C:爆破対象の数が最大となる列の番号

bomb = set(bomb)
for r in R:
    for c in C:
        # (r, c)に爆破対象が存在しないとき, maxX + maxY が答えとなることが確定するため, 
        # 即座に探索を終了する.
        if (r, c) not in bomb:
            print(maxX + maxY)
            exit()
print(maxX + maxY - 1)
### BUGGY CODE ###

import sys
input  = sys.stdin.readline

N,W=map(int,input().split())
box=[[0]*(W+1) for i in range(N+1)]

for i in range(N):
  w,v=map(int,input().split())
  for j in range(W+1):
    box[i+1][j]=max(box[i+1][j],box[i][j])
    total = j+w
    if total>W:
      continue
    else:
      box[i+1][total]=max(box[i][total], box[i][j]+v)
print(box[-1][-1])


### FIXED CODE ###

import sys
input  = sys.stdin.readline

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

def process(N,W):
  box=[0]*(W+1)
  for i in range(N):
    w,v=map(int,input().split())
    for j in range(W,0,-1):
      idx = j-w
      if idx<0:
        break
      else:
        box[j] = max(box[j],box[idx]+v)
  return box[-1]

print(process(N,W))
### BUGGY CODE ###

from collections import deque

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


import fractions
from functools import reduce

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


ans=0
GCD_target=gcd_list(A)
#print("GCD_target = {}".format(GCD_target))

for i in range(N):
   #copied_A = A[:]
   remove=A.popleft()
   GCD_current=gcd_list(list(A))
   A.append(remove)
   #print(GCD_current)
   ans=max(ans,GCD_current)

print(ans)

### FIXED CODE ###

from fractions import *
n = int(input())
a = [0]+list(map(int, input().split()))+[0]
b = [0]*(n+2)
c = [0]*(n+2)
for i in range(1, n+1):
	b[i] = gcd(b[i-1], a[i])
for i in range(n, 0, -1):
	c[i] = gcd(c[i+1], a[i])

ans=1
for i in range(1, n+1):
    x1 = b[i-1]
    x2 = c[i+1]
    ans=max(ans, gcd(x1, x2))

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

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

for i in A:
  total = total * i
if total > 10**18:
  print(-1)
else:
  print(total)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split(" ")))
total = 1
A.sort()

for i in A:
  if i == 0:
    total = 0
    break
  elif total > 10**18:
    break
  total = total * i
if total > 10**18:
  print(-1)
else:
  print(total)
### BUGGY CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import itertools
import numpy as np

A,B,C = read().decode().split()

A = np.array(list(A))
B = np.array(list(B))
C = np.array(list(C))

M = 2020

def can_match(x,y):
    L = min(len(x), len(y))
    x = x[:L]
    y = y[:L]
    return np.all((x == '?') | (y == '?') | (x == y))

def solve(A,B,C,LA,LB,LC):
    BA = [True] * (M)
    for i in range(M):
        BA[i] = can_match(A[i:], B)
    CA = [True] * (M+M)
    for i in range(M+M):
        CA[i] = can_match(A[i:], C)
    CB = [True] * (M)
    for i in range(M):
        CB[i] = can_match(B[i:], C)
    BA = np.array(BA)
    CA = np.array(CA)
    CB = np.array(CB)
    k = np.arange(M)[:,None] + np.arange(M)[None,:]
    cond = BA[:,None] & CB[None,:] & CA[k]
    length = np.maximum(LA, np.maximum((LB + np.arange(M))[:,None], (LC + k)))
    return length[cond].min()

answer = 10 ** 9
for A,B,C in itertools.permutations([A,B,C]):
    LA = len(A)
    LB = len(B)
    LC = len(C)
    x = solve(A,B,C,LA,LB,LC)
    if answer > x:
        answer = x
print(answer)

### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import itertools

A,B,C = read().decode().split()

A = list(A)
B = list(B)
C = list(C)

def can_match(x,y):
    return x == '?' or y == '?' or x == y

M = 2020

def solve(A,B,C,LA,LB,LC):
    B_from_A = [True] * (M+1)
    for i in range(M+1):
        B_from_A[i] = all(can_match(x,y) for x,y in zip(A[i:],B))
    C_from_A = [True] * (M+M+1)
    for i in range(M+M+1):
        C_from_A[i] = all(can_match(x,y) for x,y in zip(A[i:],C))
    C_from_B = [True] * (M+1)
    for i in range(M+1):
        C_from_B[i] = all(can_match(x,y) for x,y in zip(B[i:],C))
    for i in range(M):
        if not B_from_A[i]:
            continue
        for j in range(M):
            if not C_from_B[j]:
                continue
            if not C_from_A[i+j]:
                continue
            yield max(LA, LB+i, LC+i+j)
            break

answer = 10 ** 9
for A,B,C in itertools.permutations([A,B,C]):
    LA = len(A)
    LB = len(B)
    LC = len(C)
    x = min(solve(A,B,C,LA,LB,LC))
    if answer > x:
        answer = x
print(answer)
### BUGGY CODE ###

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

for k in range(1, N):
    if k<N-1:
        if A[k] == A[k+1]:
            continue
    for j in range(k):
        if A[k]%A[j] ==0:
            break
    else:
        count +=1
        #print(A[k])
if N>1:
    if A[0]%A[1] >0:
        count+=1
    
if N ==1:
    count = 1
print(count)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
count = 0
A.sort()
c=0
"""
for k in range(len(A)-1):
    if A[k] == A[k+1]:
        del A[k]
        A.insert(0,0)
        c+=1
        if k <len(A)-2:
            if A[k+1] != A[k+2]:
                del A[k+1]
                A.insert(0,0)
                c+=1
        else:
            del A[k+1]
            A.insert(0,0)
            c+=1
del A[:c]
if len(A)>0:
    saidai = A[-1]
else:
    saidai=0
#print(A)
"""
saidai = A[-1]
foo = [0 for k in range(saidai+1)]
for k in range(len(A)):
    if foo[A[k]] == 1:
        continue
    else:
        for j in range(A[k], saidai+1, A[k]):
            foo[j] = 1
        if k < len(A)-1:
            if A[k] == A[k+1]:
                continue
        if 0 < k < len(A):
            if A[k] == A[k-1]:
                continue
        count+=1
print(count)
### BUGGY CODE ###

n, *a = map(int, open(0).read().split())

ans = 1
for x in range(n):
    ans *= a[x]

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


### FIXED CODE ###

N, *a = map(int, open(0).read().split())

if 0 in a:
    print(0)
    exit()

ans = 1
for x in a:
    ans = ans * x
    if 10 ** 18 < ans:
        print(-1)
        exit()

print(ans)