Harryxun/stf_run huggingface dataset:
from functools import reduce
import fractions
 
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


n = int(input())

inp_list = list(map(int,(input().split())))

lcm = lcm_list(inp_list)

ans = 0

for i in inp_list:
    ans += lcm // i


print(ans % (10**9+7))



### FIXED CODE ###

from functools import reduce
import fractions
 
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
 
n = int(input())

inp_list = list(map(int,(input().split())))

lcm = lcm_list(inp_list)

ans = 0
mod = 10**9+7

for i in inp_list:
    ans += lcm // i



print(ans % mod)
N = int(input())
A = [int(input()) for i in range(N)]

s = 0
L = [False]*22
for a in A:
    s ^= a
    c = 0
    while a&1==0:
        c += 1
        a >>= 1
    L[c] = True
if s==0:
    print(0)
    exit()
ss = "0" + bin(s)[2:]
ans = 0
for i in range(len(ss)-1):
    if ss[-1-i] != ss[-2-i]:
        if L[i]:
            ans += 1
        else:
            print(-1)
            exit()
print(ans)


### FIXED CODE ###

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

s = 0
L = [False]*44
for a in A:
    s ^= a
    c = 0
    while a&1==0:
        c += 1
        a >>= 1
    L[c] = True
if s==0:
    print(0)
    exit()
ss = "0" + bin(s)[2:]
ans = 0
for i in range(len(ss)-1):
    if ss[-1-i] != ss[-2-i]:
        if L[i]:
            ans += 1
        else:
            print(-1)
            exit()
print(ans)
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) % 1000000007

n, k = map(int, input().split())
for i in range(1, k+1):
  print(combinations_count(k-1, i-1) * combinations_count(i+1+(n-k)-(i-1)-1, (n-k)-(i-1)) % 1000000007) 

### FIXED CODE ###

import math

def myfactorial(n):
  return math.factorial(n)

def combinations_count(n, r):
  return (myfactorial(n) // (myfactorial(n - r) * myfactorial(r))) % 1000000007

n, k = map(int, input().split())
for i in range(1, k+1):
  if n-k+1 < i:
    print(0)
  else:
    print(combinations_count(k-1, i-1) * combinations_count(n-k+1, i) % 1000000007)
S = input()
K = int(input())

if len(S)==1:
    print(S[0])
    
else:
    lst = []
    for i in range(len(S)):
        if S[i]!='1':
            lst.append(i)
        
    if K<lst[0]:
        print('1')
    else:
        print(S[lst[0]])

### FIXED CODE ###

S = input()
K = int(input())

if len(S)==1:
    print(S[0])
    
else:
    lst = []
    for i in range(len(S)):
        if S[i]!='1':
            lst.append(i)
        
    if lst==[]:
        print('1')
    else:
        if K<lst[0]+1:
            print('1')
        else:
            print(S[lst[0]])
N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]
A = set(A)

dp = [0] * N

ans = None

if N == 1:
  ans = 1

if N == 2:
  ans = 2 if 1 not in A else 1

if ans:
  print(ans)
  
dp[-1] = 1 if N-1 not in A else 0
dp[-2] = dp[-1] + 1 if N-2 not in A else dp[-1]

for i in range(N-3, -1, -1):
  if i not in A:
    dp[i] = dp[i+1] + dp[i+2]

print(dp[0] % (10 ** 9 + 7))

### FIXED CODE ###

N, M = map(int, input().split())
A = set([int(input()) for _ in range(M)])

mod = 1000000007

dp = [0] * (N + 2)
dp[N] = 1  # GOAL

for i in range(N-1, -1, -1):
  if i not in A:
    dp[i] = dp[i+1] + dp[i+2]

print(dp[0] % mod)
import sys
input = sys.stdin.readline

s = input().strip()
t = input().strip()
n = len(s)
m = len(t)
p = 0
q = 0
fold = 0
l = [[] for _ in range(26)]
lim = [0 for _ in range(26)] 
for i, x in enumerate(s):
	l[ord(x) - 97].append(i)
	lim[ord(x) - 97] += 1
r = [0 for _ in range(26)]
cur = -1
while (q < m):
	x = t[q]
	ind = ord(x) - 97
	#print(x, cur)
	if l[ind] == []:
		print(-1)
		exit(0)
	else:
		#print("HERE", r[ind], lim[ind])
		if r[ind] >= lim[ind]:
			fold += 1
			r = [0 for _ in range(26)]
			cur = -1
		else:
			c = l[ind][r[ind]]
			flag = True
			while (c <= cur):
				r[ind] += 1
				if r[ind] >= lim[ind]:
					flag = False
					break
				c = l[ind][r[ind]]
			if flag == False:
				fold += 1
				r = [0 for _ in range(26)]
				cur = -1
			elif c > cur:
				cur = c
				q += 1
				r[ind] += 1
			else:
				fold += 1
				r = [0 for _ in range(26)]
				cur = -1
#print(fold, n, cur)
print(fold * n + cur + 1)




 

### FIXED CODE ###

import sys
input = sys.stdin.readline


a = int(input())
s = input().strip()

if a >= 3200:
	print(s)
else:
	print("red")
def available(start, end, S, step=None):
    if step is not None:    #   追い越し処理
        S = S[:step] + "#" + S[step+1:]
    for i in range(start, end):
        if S[i] == "#" and S[i+1] == "#":
            return False
    return True, S
    
def overtake(start, end, S):
    for i in range(start, end+1):
        if S[i-1] == "." and S[i] == "." and S[i+1] == ".":
            step = i
            return True, step
    return False, None

N, A, B, C, D = map(int, input().split())
S = "." + input() + ".."

if D > C:   #   追い越しが不要な時
    judge1, S = available(A, C, S)
    judge2, S = available(B, D, S)
    if judge1 and judge2:
        print("Yes")
    else:
        print("No")
else:   #   追い越しが必要な時
    overtakable, step = overtake(B, D, S)
    if overtakable:   #   追い越しが可能な時
        judge1, S = available(B, D, S)
        judge2, S = available(A, C, S, step=step)
        if judge1 and judge2:
            print("Yes")
        else:
            print("No")
    else:   #   追い越しができない時
        print("No")
        

### FIXED CODE ###

def available(start, end, S, step=None):
    if step is not None:    #   追い越し処理
        S = S[:step] + "#" + S[step+1:]
    for i in range(start, end):
        if S[i] == "#" and S[i+1] == "#":
            return False, S
    return True, S
    
def overtake(start, end, S):
    for i in range(start, end+1):
        if S[i-1] == "." and S[i] == "." and S[i+1] == ".":
            step = i
            return True, step
    return False, None

N, A, B, C, D = map(int, input().split())
S = "." + input() + "."

if D > C:   #   追い越しが不要な時
    judge1, S = available(A, C, S)
    judge2, S = available(B, D, S)
    if judge1 and judge2:
        print("Yes")
    else:
        print("No")
else:   #   追い越しが必要な時
    overtakable, step = overtake(B, D, S)
    if overtakable:   #   追い越しが可能な時
        judge1, S = available(B, D, S)
        judge2, S = available(A, C, S, step=step)
        if judge1 and judge2:
            print("Yes")
        else:
            print("No")
    else:   #   追い越しができない時
        print("No")
takahashi_kun = X

if X == 3:
    print('YES')
elif X == 5:
    print('YES')
elif X == 7:
    print('YES')
else:
    print('NO')

### FIXED CODE ###

takahashi_kun = int(input())

if takahashi_kun == 3:
    print('YES')
elif takahashi_kun == 5:
    print('YES')
elif takahashi_kun == 7:
    print('YES')
else:
    print('NO')
# AtCoder
N, K = map(int, input().split())
V = list(map(int, input().split()))

ans = 0

for l in range(K+1):
    for r in range(K-l+1):
        if l+r > N:
            break
        d = K-l-r
        now = 0
        s = []
        for i in range(l+1):
            s.append(V[i])
            now += V[i]

        for i in range(N-r, N):
            s.append(V[i])
            now += V[i]

        s = sorted(s)
        for i in range(d-1):
            if i >= len(s):
                break
            if s[i] > 0:
                break
            now -= s[i]
        ans = max(ans, now)
print(ans)


### FIXED CODE ###

# AtCoder
N, K = map(int, input().split())
V = list(map(int, input().split()))
ans = 0
for l in range(K+1):
    for r in range(K-l+1):
        if l+r > N:
            break
        d = K-(l+r)

        j = V[:l]+V[N-r:]
        j.sort()

        for i in range(d):
            if not j:
                break
            elif j[0] >= 0:
                break
            j.pop(0)

        ans = max(ans, sum(j))
print(ans)
n, m, c = map(int, input().split())
b = [int(x) for x in range(m)]
ans = 0

for j in range(n):
    a = input().split()
    for i in range(m):
        sum = 0
        sum += a[i]*b[i]
    if sum > -c:
        ans += 1

print(ans)

### FIXED CODE ###

n, m, c = map(int, input().split())
b = list(int(x) for x in input().split())
ans = 0

for j in range(n):
    a = list(int(x) for x in input().split())
    sum = 0
    for i in range(m):
        sum += a[i]*b[i]
    if sum > -c:
        ans += 1

print(ans)
n, m = map(int, input().split())
p = list(map(int, input().split()))
xys = [list(map(int, input().split())) for _ in range(m)]
uf = {}

def dfs(cld):
    if cld not in uf:
        return []
    elif uf[cld] == None:
        return [cld]
    elif cld in uf:
        return dfs(uf[cld]) + [cld]

for xy in xys:
    xin = (xy[0] in uf)
    yin = (xy[1] in uf)
    xp = dfs(xy[0])
    yp = dfs(xy[1])
    if xin and yin:
        if len(xp) > len(yp):
            uf[xy[1]] = xy[0]
        else:
            uf[xy[0]] = xy[1]
    elif xin:
        uf[xy[1]] = xp[0]
    elif yin:
        uf[xy[0]] = yp[0]
    else:
        uf[xy[0]] = None
        uf[xy[1]] = xy[0]
count = 0
for i in range(n):
    num = i + 1
    pi = p[i]
    if sum(set(dfs(num)) & set(dfs(pi))) > 0:
        count += 1
    elif num == pi:
        count += 1
print(count)

### FIXED CODE ###

n, m = map(int, input().split())
p = list(map(int, input().split()))
xys = [list(map(int, input().split())) for _ in range(m)]
mapp = [[] for _ in range(n + 1)]
for xy in xys:
    mapp[xy[0]].append(xy[1])
    mapp[xy[1]].append(xy[0])

bfs = [0] * (n + 1)
count = 0
for i in range(1, n + 1):
    nexts = mapp[i]
    if not(bfs[i]):
        bfs[i] = i
    for j in nexts:
        if bfs[j]:
            continue
        bfs[j] = i
        nexts += mapp[j]
    if bfs[i] == bfs[p[i - 1]]:
        count += 1
print(count)
H, W = map(int, input().split())
S = ['.'+input()+'. ' for _ in range(H)]

S.insert(0, '.'*(W+2))
S.insert(H+1, '.'*(W+2))

flg = 0
for i in range(1, W):
    for j in range(1, H):
        if S[i][j]=='#':
            if S[i+1][j]=='.' and S[i-1][j]=='.' and S[i][j+1]=='.' and S[i][j-1]=='.':
                flg = 1
                break

if flg==0:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

H, W = map(int, input().split())
S = ['.'+input()+'. ' for _ in range(H)]

S.insert(0, '.'*(W+2))
S.insert(H+1, '.'*(W+2))

flg = 0
for i in range(1, H+1):
    for j in range(1, W+1):
        if S[i][j]=='#':
            if S[i+1][j]=='.' and S[i-1][j]=='.' and S[i][j+1]=='.' and S[i][j-1]=='.':
                flg = 1
                break
    else:
        continue
    break
    
if flg==0:
    print('Yes')
else:
    print('No')
import math
a=[input() for i in range(5)]
b,c=10,0
for i in range(5):
    if 0<int(a[i][-1])<b:
        b=int(a[i][-1])
        d=i
for i in range(5):
    if i==d:
        c+=int(a[i])
    else:
        if int(a[i][-1])==0:
            c+=int(a[i])
        elif int(a[i])<=10:
            c+=10
        else:
            c+=(int(a[i][0:-1])+1)*10
print(c)

### FIXED CODE ###

import math
a=[input() for i in range(5)]
b,c=10,0
for i in range(5):
    if 0<int(a[i][-1])<b:
        b=int(a[i][-1])
        d=i
for i in range(5):
    if b!=10:
        if i==d:
            c+=int(a[i])
        else:
            if int(a[i][-1])==0:
                c+=int(a[i])
            elif int(a[i])<=10:
                c+=10
            else:
                c+=(int(a[i][0:-1])+1)*10
    else:
        c+=int(a[i])
print(c)
d, n = map(int, input().split())
print([i*100**d for i in range(1, 101) if i != 100][n - 1])

### FIXED CODE ###

d, n = map(int, input().split())
print([i*100**d for i in range(1, 102) if i != 100][n - 1])
from sys import exit
from collections import defaultdict
n,x = open(0).read().split()
n = int(n)
cnt = x.count('1') 
digits = list(map(int, list(x)))
x = int(x, 2)

d = defaultdict(int)
d[0] = 0
def calc(m):
    if m not in d:
        nxt = m % bin(m).count('1')
        d[m] = calc(nxt) + 1
    return d[m]

if n == 1:
    print(calc(x^1))
    exit()

mmod = cnt - 1
pmod = cnt + 1

mx = x % mmod
px = x % pmod

mbase = 1
pbase = 1

ans = []
while digits:
    digit = digits.pop()
    if digit:
        ans.append(calc((mx - mbase)%mmod) + 1)
    else:
        ans.append(calc((px + pbase)%pmod) + 1)
    mbase = (mbase * 2) % mmod
    pbase = (pbase * 2) % pmod

while ans:
    print(ans.pop())

### FIXED CODE ###

from sys import exit
from collections import defaultdict
n,x = open(0).read().split()
n = int(n)
cnt = x.count('1') 
digits = list(map(int, list(x)))
x = int(x, 2)

d = defaultdict(int)
d[0] = 0
def calc(m):
    if m not in d:
        nxt = m % bin(m).count('1')
        d[m] = calc(nxt) + 1
    return d[m]

if n == 1:
    print(calc(x^1))
    exit()

mmod = cnt - 1
pmod = cnt + 1

if mmod > 0:
    mx = x % mmod
px = x % pmod

mbase = 1
pbase = 1

ans = []
while digits:
    digit = digits.pop()
    
    if digit and mmod <= 0:
        ans.append(0)
    else:
        if digit:
            nx = (mx - mbase)%mmod
        else:
            nx = (px + pbase)%pmod
        ans.append(calc(nx) + 1)

    if mmod > 0:
        mbase = (mbase * 2) % mmod
    pbase = (pbase * 2) % pmod

while ans:
    print(ans.pop())
if (A+B)%2==0:
	print((A+B)//2)
else:
	print("IMPOSSIBLE")

### FIXED CODE ###

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


if (A+B)%2==0:
	print((A+B)//2)
else:
	print("IMPOSSIBLE")
n,k=map(int,input().spulit())

print(min(n%k,k-n%k))


### FIXED CODE ###

n,k=map(int,input().split())

print(min(n%k,k-n%k))
N = int(input())
F = [[int(i) for i in input().split()] for j in range(N)]
P = [[int(i) for i in input().split()] for j in range(N)]

ci = 0
c = []
P_max = -1000000000
for i in range(2):
    for j in range(2):
        for k in range(2):
            for l in range(2):
                for m in range(2):
                    for n in range(2):
                        for o in range(2):
                            for p in range(2):
                                for q in range(2):
                                    for r in range(2):
                                        if i==j==k==l==m==n==o==p==q==r==0:
                                            pass
                                        for s in range(N):
                                            ci = F[s][0]*i + F[s][1]*j + F[s][2]*k + F[s][3]*l + F[s][4]*m + F[s][5]*n + F[s][6]*o + F[s][7]*p + F[s][8]*q + F[s][9]*r
                                            c.append(ci)
                                        P_sample = P[0][c[0]] + P[1][c[1]] + P[2][c[2]] + P[3][c[3]] + P[4][c[4]] + P[5][c[5]] + P[6][c[6]] + P[7][c[7]] + P[8][c[8]] + P[9][c[9]]
                                        P_max = max(P_max, P_sample)

print(P_max)


### FIXED CODE ###

N = int(input())
F = [[int(i) for i in input().split()] for j in range(N)]
P = [[int(i) for i in input().split()] for j in range(N)]

ci = 0
c = []
P_max = -1000000000
for i in range(2):
    for j in range(2):
        for k in range(2):
            for l in range(2):
                for m in range(2):
                    for n in range(2):
                        for o in range(2):
                            for p in range(2):
                                for q in range(2):
                                    for r in range(2):
                                        if i==0 and j==0 and k==0 and l==0 and m==0 and n==0 and o==0 and p==0 and q==0:
                                            r = 1
                                        P_sample = 0
                                        for s in range(N):
                                            ci = F[s][0]*i + F[s][1]*j + F[s][2]*k + F[s][3]*l + F[s][4]*m + F[s][5]*n + F[s][6]*o + F[s][7]*p + F[s][8]*q + F[s][9]*r
                                            P_sample += P[s][ci]
                                        P_max = max(P_max, P_sample)

print(P_max)
n=int(input())
#ne,[7,5,3,1,1,3,5,7]8
#no,[8,6,4,2,0,2,4,6,8]9
m=[0]*n
for i in map(int,input().split()):
  m[i]+=1
ans=1
for i in range(n-1,0,-2):
  if d[i]!=2:
    ans=0
if d[0]!=n%2:
  ans=0
if ans:
  print(2**(n//2)%1000000007)
else:
  print(0)
    

### FIXED CODE ###

n=int(input())
#ne,[7,5,3,1,1,3,5,7]8
#no,[8,6,4,2,0,2,4,6,8]9
m=[0]*n
for i in map(int,input().split()):
  m[i]+=1
ans=1
for i in range(n-1,0,-2):
  if m[i]!=2:
    ans=0
if m[0]!=n%2:
  ans=0
if ans:
  print(2**(n//2)%1000000007)
else:
  print(0)
n = int(input())
ans = 0
for i in range(1,n+1,2) :
  cnt = 0
    for j in range(1,i+1) :
      if i % j == 0 :
        cnt += 1
    if cnt == 8 :
      ans += 1
print(ans)     

### FIXED CODE ###

n = int(input())
cnt = 0
divisor = []
for i in range(1,n+1,2) :
        for j in range(1,i+1) :
                if i % j == 0 :
                        cnt += 1
        divisor.append(cnt)
        cnt = 0
ans = 0
for i in divisor :
        if i == 8 :
                ans += 1
print(ans)
import math

N,X = map(int,input().split())
x = list(map(int,input().split()))
if N == 1:
    print(abs(x[0] - X))
else:
    xlen = [abs(x[0]-X)]
    for i in range(N-1):
        xlen.append(x[i+1]- x[i])
    ans = xlen[0]
    for i in range(N-2):
        ans = math.gcd(ans,xlen[i+1])
    print(ans)

### FIXED CODE ###

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


N,X = map(int,input().split())
x = list(map(int,input().split()))
if N == 1:
    print(abs(x[0] - X))
else:
    xlen = []
    for i in range(N):
        xlen.append(abs(x[i] - X))
        #print(xlen[i])
    ans = xlen[0]
    for i in range(1,N):
        ans = gcd(ans,xlen[i])
        #print(ans)
    print(ans)
N, A, B = map(int, input().split())
St = ''
while len(St) < N:
    St += 'b' * A + 'r' * B
ans = 0

for i in range(0, N):
    if St[i] == 'b':
        ans += 1
    

print(ans)


### FIXED CODE ###

N, A, B = map(int, input().split())
ans = N//(A+B) * A
tmp = N%(A+B)

print(ans + min(tmp, A))
N = int(input())
number = []
    A in range(1,10)
    B in range(1,10)
    number.append(A*B)
if N in number :
  print("Yes")
else :
  print("No")

### FIXED CODE ###

N = int(input())
number = []
for a in range(1,10):
    for b in range(1,10):
        number.append(b*a)
if N in number :
    print("Yes")
else :
    print("No")
for i in range(1,10):
  for j in range(1,10);
    print('{}x{}={}', i, j, i*j)


### FIXED CODE ###

for i in range(1,10):
	for j in range(1,10):
		print("{0}x{1}={2}".format(i,j,i*j))
a,b,c = map(int,input(),split())
if a>b:
  a,b=b,a
if b>c:
  c,b=b,c
if a>b:
  a,b=b,a
print(a,b,c)



### FIXED CODE ###

a,b,c = map(int,input().split())
if a > b:
  a,b = b,a
if b > c:
  c, b = b, c
if a > b:
  a, b = b, a
print(a,b,c)
N = int(input())
A = list(map(int, input().split()))

mod = 10**9+7
#mod = 11

LCM = A[0]
for i in range(N-1):
  LCM = lcm(LCM, A[i+1])

ans = 0
for a in A:
  ans += LCM // a
  ans %= mod

print(ans)

### FIXED CODE ###

import math

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

mod = 10**9+7

def lcm(x, y):
  return (x // math.gcd(x, y)) * y

LCM = A[0]
for i in range(N-1):
  LCM = lcm(LCM, A[i+1])

LCM %= mod

ans = 0
for a in A:
  ans += LCM * pow(a, mod-2, mod) % mod
  ans %= mod

print(ans)
S=input().replace('1','x').replace('9','1').replace('x',9)
print(S)

### FIXED CODE ###

S=input().replace('1','x').replace('9','1').replace('x','9')
print(S)
def insertion(A, n, g):
    c = 0
    for i in range(g, n):
        while i >= g and A[i - g] > A[i]:
            A[i], A[i - g] = A[i - g], A[i]
            i -= g
            c += 1
    return c

def main():
    n = int(raw_input())
    A = [int(raw_input()) for i in range(n)]

    G = list()
    h = 1
    while h <= n:
        G.append(h)
        h = 3 * h + 1
    G = G[::-1]
    cnt = 0

    for i in G:
        cnt += insertion(A, n, i)

    print(len(G))
    print(" ".join(map(str, G)))
    print(cnt)
    for j in A: print(j)

main()

### FIXED CODE ###

def insertion(A, n, g):
    cnt = 0
    for i in range(g, n):
        while i >= g and A[i - g] > A[i]:
            A[i], A[i - g] = A[i - g], A[i]
            i -= g
            cnt += 1
    return cnt

def main():
    n = int(raw_input())
    A = [int(raw_input()) for i in range(n)]

    G = list()
    h = k = 1
    while h <= n:
        G.append(h)
        h = (4 ** k) + (3 * (2 ** (k - 1)) + 1)
        k += 1
    G = G[::-1]

    cnt = 0
    for i in G:
        cnt += insertion(A, n, i)

    print(len(G))
    print(" ".join(map(str, G)))
    print(cnt)
    for j in A: print(j)

main()
import math

x = int(input())
ans = [1]
s = math.sqrt(x)
if s >= 2:
    for i in range(2,s+1):
        temp = i
        while True:
            temp *= i
            if temp <= n:
                ans.append(temp)
            else:
                break

print(max(ans))

### FIXED CODE ###

import math

x = int(input())
ans = [1]
s = int(math.sqrt(x))
if s >= 2:
    for i in range(2,s+1):
        temp = i
        while True:
            temp *= i
            if temp <= x:
                ans.append(temp)
            else:
                break

print(max(ans))
o = input()
e = input()

for i in range(len(o)):
    print(o[i]+e[i], end="")

if len(o) != len(e):
    print(o[len(o)-1])


### FIXED CODE ###

o = input()
e = input()

for i in range(len(e)):
    print(o[i]+e[i], end="")


if len(o) != len(e):
    print(o[-1])
def main():
    n=int(input())
    task=[]
    for i in range(n):
        a,b=map(int,input().split())
        task.append([b,a])
    task.sort()
    t=0
    ans="Yes"
    for i in range(n):
        t+=task[i][1]
        if t>task[i][0]:
            ans="No"
            break
    print(ans)
if __name__=="__main__":
    main()def main():
    n=int(input())
    task=[]
    for i in range(n):
        a,b=map(int,input().split())
        task.append([b,a])
    task.sort()
    t=0
    ans="Yes"
    for i in range(n):
        t+=task[i][1]
        if t>task[i][0]:
            ans="No"
            break
    print(ans)
if __name__=="__main__":
    main()

### FIXED CODE ###

n=int(input())
task=[]
for i in range(n):
    a,b=map(int,input().split())
    task.append([b,a])
task.sort()
t=0
ans="Yes"
for i in range(n):
    t+=task[i][1]
    if t>task[i][0]:
        ans="No"
        break
print(ans)
def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

N = int(input())
ans = 1

for i in range(0,N):
    t = int(input())
    ans = int((ans / gcd(ans, t) * t))

print(ans)

### FIXED CODE ###

def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

N = int(input())
ans = 1

for i in range(0,N):
    t = int(input())
    ans = t * ans // gcd(ans, t)

print(ans)
def main():
    import sys
    sys.setrecursionlimit(10**9)
    input = sys.stdin.readline

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

    limit = 10**18
    ans = 1
    for i in A:
        if A == 0:
            print(0)
            return
        if ans > limit:
            print(-1)
            return
        ans *= A[i]
    print(ans)

main()

### FIXED CODE ###

def main():
    import sys
    sys.setrecursionlimit(10**9)
    input = sys.stdin.readline

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

    if 0 in A:
        print(0)
        return

    limit = 10**18
    ans = 1
    for i in A:
        ans *= i
        if ans > limit:
            print(-1)
            return

    print(ans)

main()