peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
#

import sys
input=sys.stdin.readline

def main():
    N,A,B=map(int,input().split())
    cnt=0
    for i in range(1,N+1):
        ds=0
        for j in range(4):
            ds+=(i//(10**j))%(10**j)
        if A<=ds<=B:
            cnt+=i
    print(cnt)
    
if __name__=="__main__":
    main()
# Judge status: Wrong Answer
x, buy, eat = map(int,input().split())

if buy > eat:
    print("delicious")
elif eat-buy < x:
    print("safe")
elif eat - buy > x:
    print("dangerous")
# Judge status: Accepted
n = int(input())
a = [int(input()) for _ in range(n)]

ans = set()
for each in a:
  if each in ans:
    ans.remove(each)
  else:
    ans.add(each)
    
print(len(ans))
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
k=int(input())
l=[]
if k>=2:
  l.append(pow(a,k) +b+c)
  l.append(pow(b,k) +a+c)
  l.append(pow(c,k) +a+b)
else:
  l.append((k+1)*a +b+c)
  l.append((k+1)*b +a+c)
  l.append((k+1)*c +a+b)
print(max(l))
# Judge status: Accepted
N, M = map(int, input().split())
X = list(map(int, input().split()))
xs = sorted(X)
d = []
for i in range(M-1):
  d.append(xs[i+1]-xs[i])
ds = sorted(d)
if M>N:
  print(sum(ds[:(M-N)]))
else:
  print(0)
# Judge status: Wrong Answer
n = int(input())
num = len(str(n))
if num&1==1:
    ans = (n%(10**(num-1)))+1
    num -=2
else:
    ans = 0
    num -= 1
n %= 10**num
while num>0:
    ans += 9*(10**(num-1))
    num -=2
    n %= 10**num
print(ans)
# Judge status: Wrong Answer
w,a,b=map(int,input().split())
print(abs(b-a-w) if b-a>=0 else abs(a-b-w))
# Judge status: Accepted

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

a.sort(reverse=True)

res= sum(a[0::2])-sum(a[1::2])

print(res)
# Judge status: Accepted
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    TF = 'No'
    for i in range(25):
        if N-4*i<0:
            break
        elif (N-4*i)%7==0:
            TF='Yes'
            break
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(TF)
# Judge status: Accepted
a, b, c = map(int, input().split())

for i in range(1, 100):
  if (a * i) % b == c:
    print("YES")
    exit()
else:
  print("NO")
# Judge status: Accepted
n = int(input())
ass = list(map(int, input().split(' ')))

count = 1
sign = 0
for i in range(n - 1):
    if sign == 0:
        sign = (ass[i + 1] - ass[i]) 
    else:
        if (ass[i + 1] - ass[i]) * sign < 0:
            count += 1
            sign = 0
print(count)
# Judge status: Wrong Answer
import itertools

N, K = map(int, input().split())
H = [int(input()) for i in range(N)]

ans = float("inf")

for s in itertools.permutations(H, K):
  list(s).sort()
  ans = min(ans, H[K-1] - H[0])
  
print(ans)
# Judge status: Accepted
S=input()
K=int(input())
ans=1
for i in range(K):
    if (S[i]!='1'):
        ans=S[i]
        break
print(ans)
# Judge status: Accepted
n,m = map(int, input().split())
lst = [[] for i in range(m)]
for i in range(m):
    pi,si = map(str, input().split())
    lst[i] = (int(pi),si)

ac = 0
wa = 0
status = [0 for i in range(n)]

for i in lst:
    if status[i[0]-1]!="AC" and i[1]=="AC":
        ac += 1
        wa += status[i[0]-1]
        status[i[0]-1] = "AC"
    elif status[i[0]-1]!="AC" and i[1]=="WA":
        status[i[0]-1] += 1

print(ac,wa)
# Judge status: Wrong Answer
N, K = map(int, input().split())

num_of_digits = 1

while N > K ** num_of_digits:
    num_of_digits += 1

print(num_of_digits)
# Judge status: Accepted
## D
MOD = 10**9 + 7
n = int(input())
A = list(map(int,input().split()))

m = 1
ans = 0
for i in range(60):
  s = sum([a&m for a in A])
  s//=m
  ans = (ans + (n-s)*s * m) % MOD
  m <<= 1
  
print(ans)
# Judge status: Accepted
c = [list(map(int, input().split())) for i in range(3)]
print("Yes" if c[0][0] + c[1][2] + c[2][1] == c[2][2] + c[0][1] + c[1][0] == c[0][2] + c[1][1] + c[2][0] else "No")
# Judge status: Accepted
N, T = map(int, input().split())
ct = [list(map(int, input().split())) for _ in range(N)]

ans = 'TLE'
for ci, ti in ct:
    if ti > T: continue
    #
    if ans == 'TLE':
        ans = ci
    else:
        ans = min(ans, ci)

print(ans)
# Judge status: Accepted
print("YES" if int("".join(list(map(str, input().strip().split())))) % 4 == 0 else "NO")
# Judge status: Accepted
# 解説AC
S = input()
N = len(S)

cnt = [0] * 2019

cnt[0] = 1

ans = 0
e = 1; cur = 0
for s in reversed(S):
    cur = (cur + int(s) * e) % 2019

    ans += cnt[cur]

    e = (e * 10) % 2019
    cnt[cur] += 1

print(ans)
# Judge status: Accepted
n=int(input())
if n%2==1:
  print(((n//2)+1)/n)

else:
  print(1/2)
# Judge status: Wrong Answer
N=int(input())
List = list(map(int, input().split()))
flag = 0
for i in range(N):
  if List[i] == i+1:
    pass
  else:
    flag += 1
if flag==2 or 0:
  print("YES")
else:
  print("NO")
# Judge status: Accepted
n = int(input())
c = input()
r = 0
left, right = 0, n-1
while left < right:
    if c[left] == 'W' and c[right] == 'R':
        r += 1
        left += 1
        right -= 1
        continue
    if c[left]=='R':
        left += 1
    if c[right]=='W':
        right -= 1
print(r)
# Judge status: Accepted
s = list(input()) #sys.stdin.readlineは最後が改行
k = int(input())

now = 0

while k>0 and now<len(s):
    if s[now]=='a':
        now+=1
        continue
    tmp = ord('z')-ord(s[now])+1
    if tmp<=k:
        s[now] = 'a'
        k -= tmp
        now+=1
    else:
        now+=1

if k>0:
    s[-1] = chr(ord(s[-1])+k%26 )

print(*s,sep='')
# Judge status: Wrong Answer
N=int(input())
a=list(map(int,input().split()))
b=[0 for _ in range(N)]
for i in range(N):
    j=N-1-i
    if sum(b[j:N:j+1])%2!=a[j]:
        b[j]=1

for k in range(N):
    if b[k]==1:
        if k<N-1:
            print(k+1,end=" ")
        else:
            print(k+1)
# Judge status: Wrong Answer
n, a, b = map(int,input().split())
 
x = int(n/(a+b)) #何周目か
y = n%(a+b) 
ans = x * a + y

print(ans)
# Judge status: Accepted
N = int(input())
count = 0
for i in range(1,10):
    n = N / i
    if n.is_integer() and n <= 9:
        count +=1
if count >= 1:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
import math

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

def binary_search(ng=0, ok=max(a)):
    if ok - ng < 2: return ok
    mid = (ok + ng) // 2
    cnt = 0
    for i in a:
        cnt += math.ceil(i / mid) - 1
    if cnt <= k:
        return binary_search(ng, mid)
    else:
        return binary_search(mid, ok)
print(binary_search())
# Judge status: Accepted
n,k =map(int, input().split())
line = list(map(int, input().split()))

line.sort()
print(sum(line[0:k]))
# Judge status: Accepted
n, m, k = map(int, input().split())
ans = 'No'
for i in range(n+1):
    for j in range(m+1):
        if m * i + ( n - (2*i) ) * j == k:
            ans = 'Yes'
            break
print(ans)
# Judge status: Wrong Answer
X = input()[::-1]
n = len(X) # even

# 最後のTの後にあるSの個数

cnt = 0
for i in range(n):
	if X[i] == 'T':
		break
	cnt += 1

print(2 * cnt)
# Judge status: Wrong Answer
def gcd(a, b):
  if a <= b:
    a, b = b, a
  while a % b:
  	a, b = b, a % b
  return a

def lcm(a, b):
  return int(a * b / gcd(a, b))

A, B = map(int, input().split())
print(lcm(A, B))
# Judge status: Accepted
s = input()
cnt = 0
ans = 0
for c in s:
  if c in 'ACGT':
    cnt += 1
    ans = max(ans, cnt)
  else:
    cnt = 0
print(ans)
# Judge status: Accepted
N = int(input())
L = list(map(int, input().split()))

tmp = 10 ** 10
count = 0
for i in range(N):
    if tmp >= L[i]:
        count += 1
    tmp = min(tmp, L[i])
        
print(count)
# Judge status: Accepted
import sys

ans = []
a = list(map(int,input().split()))
for i in range(5):
    if a[i] == 0:
        ans.append(i+1)
for i in ans:
    print(i)
# Judge status: Wrong Answer
a, b, t = open(0)
n, k = map(int, a.split())
r, s, p = map(int, b.split())
d = {"r": p, "s": r, "p": s}
l = [0]*n
for i, s in enumerate(list(t.strip())):
  c = d[s]
  if l[i-k] != c:
    l[i] = c
print(sum(l))
# Judge status: Wrong Answer
import math
from itertools import accumulate

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

fromright = list(accumulate(a, math.gcd))
a.reverse()
fromleft = list(accumulate(a, math.gcd))
fromleft.reverse()

gcd = []

gcd.append(fromleft[1])

for i in range(1, n-1):
  gcd.append(math.gcd(fromright[i-1], fromleft[i+1]))

gcd.append(fromright[1])

if n == 2:
  print(math.gcd(a[1], a[0]))
else:
  print(max(gcd))
# Judge status: Accepted
print('YNeos'[input().count('9')<1::2])
# Judge status: Wrong Answer
s=input()
a=''
b=0
c=1
d=0
for i in range(len(s)):
	if s[b:c] != a:
		a=s[b:c]
		b=i
		c=i+1
		d+=1
	else:
		c=i+1
print(d)
# Judge status: Wrong Answer
N,M = map(int, input().split())
A = [list(map(int,input().split()))]
print(A)
SUM = sum(A[0])
if SUM>N:
    print(-1)
else:
    print(N-SUM)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))
list.sort(A)
print(A[1])
# Judge status: Accepted
x,y,a,b,c=map(int,raw_input().split())
p=map(int,raw_input().split())
q=map(int,raw_input().split())
r=map(int,raw_input().split())

a=[]
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

u=p[0:x]
v=q[0:y]
if len(r)<x+y:
    w=r
else:
    w=r[0:x+y]

A=u+v+w
A.sort(reverse=True)
print sum(A[0:x+y])
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))
a = list(set(A))
a.sort(reverse=True)

ans = []
for i in range(len(a)):
  if A.count(a[i]) < 2: continue
  if A.count(a[i]) >= 4:
    ans += [a[i], a[i]]
    break
  else:
    ans.append(a[i])
    if len(ans) == 2: break
print(ans[0] * ans[1] if len(ans) == 2 else 0)
# Judge status: Accepted
import sys


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


x, y, a, b, c = map(int, input().split())
P = sorted(list(map(int, input().split())), reverse=True)[:x]
Q = sorted(list(map(int, input().split())), reverse=True)[:y]
R = list(map(int, input().split()))

print(sum(sorted(P + Q + R, reverse=True)[:x + y]))
# Judge status: Accepted
S = input()
K = int(input())
for k in range(K):
    if S[k] != '1':
        print(S[k])
        exit()
print(1)
# Judge status: Accepted
a,b,t = map(int,input().split())
print(t//a*b)
# Judge status: Accepted
N, M, K = map(int, input().split())

for n in range(N + 1):
    for m in range(M + 1):
        tmp = m * (N - n) + n * (M - m)
        if tmp == K:
            print ('Yes')
            exit()

print ('No')
# Judge status: Wrong Answer
X,Y = map(int,input().split())

turu = (4*X - Y) // 2

kame = X - turu

if turu > 0 and (4*kame + 2*turu == Y):
  print("Yes")
else:
  print("No")
# Judge status: Accepted
d, t, s = map(int, input().split())
if d <= t * s:
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
h, n = map(int, input().split())
a = sum(set(map(int, input().split())))
print("Yes") if a >= h else print("No")
# Judge status: Accepted
import math
a=0
N, K = map(int,input().split())
for i in range(1, N+1):
    if i < K:
        a += (1/2)**(math.ceil(math.log2(K/i)))
    else:
        a = a + 1
a =a/N
print(a)
# Judge status: Accepted
def main():
    n = int(input())
    h_list = list(map(int, input().split()))
    highest = h_list[0]
    is_able = True

    for h in h_list:
        if highest > h:
            is_able = False
            break

        if highest + 1 < h:
            highest = h - 1

    if is_able:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()
# Judge status: Accepted
l = int(input())
m = l / 3
print(m**3)
# Judge status: Accepted
a,b = map(int,input().split())

import math
print(math.ceil((b - 1) / (a-1)))
# Judge status: Accepted
A,B,C = map(int,input().split())
K = int(input())

#A < B < C
for i in range(K):
    if A >= B:
        B *= 2
    elif B >= C:
        C *= 2
    if A < B < C:
        print('Yes')
        exit()
print('No')
# Judge status: Accepted
x = int(input())

beki = {1}
for b in range(2,32):
    for p in range(2,10):
        if b**p<=x:
            beki.add(b**p)
        else:
            break
            
beki = sorted(beki)
            
print(beki.pop(-1))
# Judge status: Accepted
w, a, b = map(int, input().split())
if a <= b:
    if a+w < b:
        print(b-a-w)
    else:
        print(0)
else:
    if b+w < a:
        print(a-b-w)
    else:
        print(0)
# Judge status: Accepted
#140
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

res = 0
for i in range(0,n):
    res += b[a[i]-1]
    if i > 0 and a[i]-1 == a[i-1]:
        res += c[a[i-1]-1]
        
print(res)
# Judge status: Accepted
S = set(list(input()))

if len(S) == 2:
	print('Yes')
else:
	print('No')
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

answer = 10 ** 15
for i in range(-100, 101):
  tmp = 0
  for a in A:
    tmp += (a - i) ** 2
  answer = min(answer, tmp)

print(answer)
# Judge status: Wrong Answer
def main():
    a, b = map(int, input().split())
    eight = [i for i in range(0, 101) if a == int(i * 0.08)]
    ten = [i for i in range(0, 101) if b == int(i * 0.1)]
    for i in eight:
        for j in ten:
            if i == j:
                print(i)
                return
    print(-1)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
n,T= map(int,input().split())
min = 1000
for i in range(n):
    c,t = map(int,input().split())
    if T >= t and min > c:
        min = c
if min > 1000:
    print('TLE')
else:
    print(min)
# Judge status: Wrong Answer
n, yen = list(map(int, input().split()))

for x in range(n+1):
  for y in range(n+1):
    z = n - x - y
    r = (10000*z) + (5000*x) + (1000*y)
    if r == yen:
      print(z, x, y)
      exit()
print(-1, -1, -1)
# Judge status: Accepted
s=list(map(int,input().split()))
s.sort()
s.reverse()
print(s[0]*10+s[1]+s[2])
# Judge status: Accepted
n,*ab = map(int,open(0).read().split())
a = sorted(ab[::2])
b = sorted(ab[1::2])
m = (n-1)//2
if n % 2 == 0:
  print(b[m]-a[m]+b[m+1]-a[m+1]+1)
else:
  print(b[m]-a[m]+1)
# Judge status: Wrong Answer
LCOS = list(map(int, input().split()))
N = int(input())

lcos = [LCOS[0], LCOS[1]/2, LCOS[2]/4, LCOS[3]/8]
llit = [0.25, 0.5, 1.0, 2.0]

lcombi = list()
for i, j, k in zip(LCOS, lcos, llit):
    lcombi.append((i, j, k))
#print(lcombi)

lup = sorted(lcombi, key=lambda x: x[1])
#print(lup)

mny = 0
for i in range(4):
    mny += lup[i][0] * (N//lup[i][2])
    N -= lup[i][2] * (N//lup[i][2])
    if N == 0:
        break
print(int(mny))
# Judge status: Accepted
A,B,K=map(int,input().split())
a=[x for x in range(1,A+1) if A%x==0 and B%x==0]
print(a[-K])
# Judge status: Accepted
print((1+sum(map(int,input().split())))//2)
# Judge status: Accepted
n, a, b, c, d = map(int, input().split())
s = input()

if '##' in s[a-1:d]:
    print('No')
    exit()

if c < d:
    print('Yes')
    exit()

if '...' in s[b-2:d+1]:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
print(pow(int(input()) / 3, 3))
# Judge status: Wrong Answer
a,b,c = map(int,input().split())
if b*c <= a:
    print(c)
else:
    print(b//a)
# Judge status: Accepted
import math

k = int(input())
a = []
result = []

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

for i in range(1,k+1):
    result.extend(math.gcd(n,i) for n in a)

print(sum(result))
# Judge status: Accepted
import math
def combinations(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
n,p=map(int,input().split())
a=list(map(int,input().split()))
n0=0
n1=0
ans=0
for i in range(len(a)):
  if a[i]%2:
    a[i]=1
    n1+=1
  else:
    a[i]=0
    n0+=1
s=sum(a)
for i in range(0,s+1,2):
  ans+=combinations(n1,i)
  if p==1 and s==0:
    print(0)
    exit()
print(ans*(2**n0))
# Judge status: Wrong Answer
s = list(input())
n = len(s)
ans = 0
for i in range(1,n):
    ans += 1
    if s[i] == s[i-1]:
        s[i]=str(1-int(s[i]))
    ans += 1
print(ans)
# Judge status: Accepted
n = int(raw_input())
ais = map(int, raw_input().split(' '))

def f(ais,n):
	q = 1 # number of non leaves
	r = 0
	h = {}
	for depth,nl in enumerate(ais):
		if nl > q: return -1
		elif nl == q:
			if depth < n: return -1
			q -= nl
		elif nl < q:
			q -= nl
		#r += (q + nl)
		h[depth] = q
		if depth < n: q *= 2
	
	internal = 0
	for j in range(len(ais)-1, 0, -1):
		r += ais[j] + internal
		internal = min(h[j - 1], ais[j] + internal) 
	return r + 1


print f(ais,n)
# Judge status: Wrong Answer
N = int(input())

A=  N//100
B = (N//10)%10
C = N%10

if (A==7) or (B==7) or (B==7):
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))
each = [0] * N

for i in range(N):
  if i + 1 == A[i]:
    each[i] = 1
    
#print(each)
ans = 0
for i in range(N):
  if i < N - 1:
    if each[i] == 1:
      if each[i + 1] == 1:
        ans += 1
        each[i + 1] = 0
      else:
        ans += 1
  #print(each, ans)      
print(ans)
# Judge status: Accepted
n, k = map(int, input().split())
print('0') if n%k == 0 else print('1')
# Judge status: Wrong Answer
import sys
import itertools

N,M,Ql = map(int, sys.stdin.readline().strip().split())
Q = []
for _ in range(Ql):
    Q.append(list(map(int, sys.stdin.readline().strip().split())))

max = 0
for A in itertools.combinations(range(1,M+1), N):
    ans = 0
    for Qi in Q:
        # print(A)
        # print(Qi)
        a,b,c,d = Qi

        if (A[b-1] - A[a-1]) == c:
            ans += d
        # print(ans)
    print()
    if max < ans:
        max = ans

print(max)
# Judge status: Accepted
a,b,c,d = map(int, input().split())

ac = a*c
ad = a*d
bc = b*c
bd = b*d

print(max(ac,ad,bc,bd))
# Judge status: Accepted
n=int(input())
ans=0
for i in range(1,n+1):
    ans+=n//i
    if n%i==0:
        ans-=1
print(ans)
# Judge status: Wrong Answer
N = input()

for i in range(2):
  if N[i] < N[i + 1]:
    print(N[1]*3)
    exit()
  elif N[i] > N[i + 1]:
    print(N[0] * 3)
    exit()
print(N)
# Judge status: Accepted
W,H,x,y=map(int,input().split())
a=W*H/2
print(a,1) if W/2==x and H/2==y else print(a,0)
# Judge status: Wrong Answer
S = list(input())
print(S)

if S[2] == S[3] and S[4] == S[5]:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
import collections
n = int(input())
a = list(map(int,input().split()))
c = collections.Counter(a)
c_value = list(c.values())
c_key = list(c.keys())
cnt = 0

for i in range(len(c_key)):
    if c_key[i] > c_value[i]:
        cnt += c_value[i]
    elif c_value[i] > c_key[i]:
        cnt += c_value[i]- c_key[i]
print(cnt)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int,input().split()))
wa = []
suma = sum(a)
for i in range(n):
    wa.append(sum(a[0:i+1]))
ans = []
for i in range(n-1):
    ans.append(suma - wa[i])
print(min(ans))
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline

s = str(input())
print(len(s) * "x")
# Judge status: Wrong Answer
k,x=map(int,input().split())
a=list(range(-k+1,k))
for b in a:
  print(x+b,end="",sep="")
# Judge status: Accepted
ints = list(map(int, input().split()))
A = ints[0]
B = ints[1]
X = ints[2]
if A > X or A+B < X:
    print("NO")
else:
    print("YES")
# Judge status: Accepted
import sys
input=sys.stdin.readline
n=int(input())
a=list(map(int,input().split()))
count={}
for i in range(1,n):
    x=i-a[i]
    if x in count:
        count[x]+=1
    else:
        count[x]=1
ans=0
for i in range(n-1):
    x=i+a[i]
    if x in count:
        ans+=count[x]
    count[i+1-a[i+1]]-=1
print(ans)
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline
n,x=map(int,input().split())
a=list(map(int,input().split()))
ans=0
if a[0]>x:
    ans+=a[0]-x
for i in range(1,n):
    if a[i]+a[i-1]>x:
        ans+=a[i]-(x-a[i-1])
        a[i]=x-a[i-1]
#print(a)
print(ans)
# Judge status: Wrong Answer
import math
l=10**9+7

n,a,b=map(int,input().split())
comb=[1]
for i in range(max(a,b)):
    den=i+1
    num=n-i
    ans=comb[i]*num*pow(den,l-2,l)%l
    comb.append(ans)


print(pow(2,n,l)-1-comb[a]-comb[b])
# Judge status: Accepted
a, b = map(int, input().split())

if a >=10 or b >=10:
    print(-1)
else:
    print(a*b)
# Judge status: Accepted
alpha = input()

Latter = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
          'K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']

if alpha in Latter:
  print('A')
else:
  print('a')
# Judge status: Wrong Answer
S=str(input())
N=len(S)
M=int((N-1)/2)
sum=0
for i in range(M):
    if S[i]==S[M-i-1]:
        sum += 1
for i in range(M+1,N):
    if S[i]==S[M-i]:
        sum += 1
if sum==(N-1):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
from collections import Counter


def solve(n, arr):
    if arr[0] != 0:
        return 0

    c = Counter(arr)

    if c[0] != 1:
        return 0

    for i in range(max(c) + 1):
        if i not in c:
            return 0

    c = list(c.items())
    c.sort()

    prev = 1
    ans = 1
    mod = 998244353

    for _, i in c[1:]:
        ans *= prev**i % mod
        ans %= mod
        prev = i

    return ans


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

print(solve(n, arr))
# Judge status: Accepted
n = int(input())
s = [int(x) for x in list(input().split()) if int(x)%2 == 0]
ans = "APPROVED"
for i in s:
  if i%5 != 0 and i%3 != 0:
    ans = "DENIED"
    pass
print(ans)
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-
def main():
    N,M = map(int,input().split())
    L = []
    R = []
    for _ in range(M):
        l,r = map(int,input().split())
        L.append(l)
        R.append(r)
    L.sort(reverse=True)
    R.sort()
    lmax = L[0]
    rmin = R[0]
    print(max(0,rmin-lmax)+1)



if __name__ == '__main__':
    main()
# Judge status: Accepted
li = list(map(int,input().split()))
li.sort()
print(li[0] + li[1])
# Judge status: Wrong Answer
a, b = list(map(int,input().split()))
a, b = str(a), str(b)
L = [a, b]
n = ''.join(L)
n = int(n)

for i in range(101):
   if n == i ** 2:
      print('Yes')
      exit()
print('No')
# Judge status: Accepted
n,h=map(int,input().split())
a=[0]*n
b=[0]*n
for i in range(n):
    a[i],b[i]=map(int,input().split())
a_max=max(a)
b.sort()
ans=0
for bi in b[::-1]:
    if bi>a_max and h>0:
        h-=bi
        ans+=1
    else:
        break
if h>0:
    ans+=-(-h//a_max)
print(ans)
# Judge status: Accepted
a, b = map(int, input().split())
print((a+b-3)//(a-1))
# Judge status: Accepted
n = int(input())
cs = input()
b=[]
for i in range(n):
  if cs[i] == "W":
    b.append(0)
  else:
    b.append(1)
a= sum(b)
ans = a- sum(b[:a])
print(ans)
# Judge status: Accepted
import fractions

a,b = map(int,input().split())

print(a*b//fractions.gcd(a,b))
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

s = sum(A)

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

ans = 10 ** 20

for i in range(N):
    ans = min(ans, abs(s - 2 * A[i]))

print(ans)
# Judge status: Accepted
x = int(input())
if x % 11 == 0:
    print((x // 11) * 2)
elif x % 11 < 7:
    print((x // 11) * 2 + 1)
else:
    print((x // 11) * 2 + 2)
# Judge status: Accepted
from collections import defaultdict
from collections import deque
import itertools
import copy

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

s = input()

l = len(s)-7


w = "keyence"
j=0
for i in range(len(s)):
	if s[i]==w[j]:
		j+=1
	else:
		if s[i+l:]==w[j:]:
			print("YES")
		else:
			print("NO")
		exit()

print("YES")
# Judge status: Accepted
n=int(input())
a=[0]*(n+1)
b=[0]*n
a[:]=map(int,input().split())
b[:]=map(int,input().split())

r=sum(a)
minab=min(a[0],b[0])
a[0]-=minab
b[0]-=minab
for ii in range(n):
  minab=min(a[ii+1],b[ii])
  a[ii+1]-=minab
  b[ii]-=minab
  if ii+1<n:
    minab=min(a[ii+1],b[ii+1])
    a[ii+1]-=minab
    b[ii+1]-=minab
print(r-sum(a))
# Judge status: Accepted
import fractions
a,b=map(int,input().split())
print((a*b)//(fractions.gcd(a,b)))
# Judge status: Accepted
import bisect
def main():
    N = int(input())
    A = sorted([int(_) for _ in input().split()])
    r = A[-1]//2
    B = A[:-1]
    x = bisect.bisect_left(B, r)
    if x == 0:
        return A[-1], B[x]
    elif x == N-1:
        return A[-1], B[x-1]
    else:
        if abs(B[x]-r) <= abs(B[x-1]-r): return A[-1], B[x]
        else: return A[-1], B[x-1]
if __name__ == '__main__':
    print(*main())