peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
if v <= w:
  print("NO")
elif a <= b:
  if a+v*t >= b+w*t:
    print("YES")
  else:
    print("NO")
else:
  if a-v*t <= b-w*t:
    print("YES")
  else:
    print("NO")
# Judge status: Accepted
a,b,c=input().split()
a=int(a)
b=int(b)
c=int(c)

d=c-(a+b)
# print(d)
if(d>0):
    l=4*a*b
    if(d*d>l):
        print("Yes")
    else:
        print("No")
else:
    print("No")
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

sita_maxi = [0 for i in range(n+1)]
sita_maxi[n] = a[n]
for i in range(n-1, -1, -1):
    sita_maxi[i] = sita_maxi[i+1] + a[i]

if a[0] > 1:
    print(-1)
    exit()

lst = [1]
for i in range(1, n+1):
    lst.append(min((lst[i-1]-a[i-1])*2, sita_maxi[i]))
    if lst[-1] < a[i]:
        print(-1)
        exit()

print(sum(lst))
# Judge status: Wrong Answer
n = int(input())
s = input()
q = [chr(i) for i in range(65,65+26)]
ans = []
for i in s:
  al = q.index(i)
  if al + n >= 26:
    al -= 26
  print(q[al],end='')
# Judge status: Accepted
x, n = map(int, input().split())
if n == 0:
    print(x)
    exit()
    
P = set(map(int, input().split()))

d_min = 1000
ans = 1000
for num in range(-1, 102):
    if num in P:
        continue
    
    d = abs(x-num)
    if d < d_min:
        d_min = d
        ans = num

print(ans)
# Judge status: Wrong Answer
a,b,c=list(map(int,input().split()))
k=int(input())
m=max(a,b,c)
s=sum([a,b,c])-m
print(s,m)
print(s+(m*2)*k)
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline
import math

X,Y=map(int,input().strip().split())

print(1 + math.floor(math.log2(Y/X)))
# Judge status: Wrong Answer
s = input()

if s[-1] == "s":
    print(s[:-1]+"es")
else:
    print(s+"s")
# Judge status: Wrong Answer

a, b = map(int, input().split())
product = a * b
print('even' if product % 2 == 0 else 'odd')
# Judge status: Accepted
N=int(input())
K=int(input())
X=int(input())
Y=int(input())

if N>=K:
    print(X * K + (N - K) * Y)
else:
    print(N*X)
# Judge status: Accepted
n = int(input())
a= list(map(int, input().split()))
s = [0]*n
ans2 = []
for i in range(1, n+1):
  temp = sum(s[n-i::n+1-i])
  if (temp % 2 == 0 and a[-i] == 1) or (temp % 2 == 1 and a[-i] == 0) :
    s[-i] = 1
    ans2.append(str(n+1-i)) 

ans2.reverse()
print(sum(s))
print(" ".join(ans2))
# Judge status: Accepted
N = int(input())
x,y = [],[]
for i in range(N):
    X,Y = [float(e) for e in input().split()]
    x.append(X)
    y.append(Y)

import itertools

ans = []
for order in itertools.permutations([i for i in range(N)]):
    r = 0.0
    for i in range(1,N):
        r += ((x[order[i]]-x[order[i-1]])**2 + (y[order[i]]-y[order[i-1]])**2) ** 0.5
    ans.append(r)

import numpy as np
print(np.mean(ans))
# Judge status: Accepted
def fl(x):
    digits = 30
    form = '%.'+str(digits-1)+'e'
    return float((form % x))

L=int(input())
print(fl((L*L*L/27)))
# Judge status: Accepted
N, x = map(int, input().split())
a = list(map(int, input().split()))
p = x
a.sort()
count = 0

for i in a:
  if x - i >= 0:
    x -= i
    count += 1
if x > 0 and count != 0  and p > sum(a):
  count -= 1
print(count)
# Judge status: Accepted
x = int(input())
ans = 8 - (x - 400) // 200
if ans < 1:
    ans = 1

print(ans)
# Judge status: Accepted
A, B, C = map(int, input().split())


def func(x):
    cnt = 0
    while x % 2 == 0:
        x //= 2
        cnt += 1

    return cnt


if A % 2 or B % 2 or C % 2:
    print(0)
elif A == B == C:
    print(-1)
else:
    m = min(func(A + B), func(B + C), func(C + A))
    print(m)
# Judge status: Accepted
N = int(input())

n = int((N ** (1/2))) + 1
ans = N
for i in range(1, n):
  if N % i == 0:
    ans = min(i + N//i - 2, ans)
print(ans)
# Judge status: Accepted
N,M=map(int,input().split())
H=list(map(int,input().split()))
good=[1 for _ in range(N)]

for i in range(M):
    A,B=map(int,input().split())
    if H[A-1]==H[B-1]:
        good[A-1]=0
        good[B-1]=0
    elif H[A-1]>H[B-1]:
        good[B-1]=0
    else:
        good[A-1]=0 

print(sum(good))
# Judge status: Accepted
N,M=map(int,input().split())
A=list(map(int,input().split()))

if sum(A)>N:
    print(-1)
else:
    print(N-sum(A))
# Judge status: Wrong Answer
n, m = map(int, input().split())
x = sorted(list(map(int, input().split())))
d = []
if m==1:
    print(0)
elif n>=m:
    print(1)
elif n<m:
    for i in range(m-1):
        d.append(x[i+1] - x[i])
    print(sum(sorted(d)[:m-n]))
# Judge status: Accepted
C = input()
ans = (chr(ord(C)+1))
print(ans)
# Judge status: Wrong Answer
N, M = map(int, input().split())
ac = [0]*N
wa = [0]*N

for m in range(M):
    p, s = input().split()
    p = int(p) - 1
    if s == 'AC' and ac[p] == 0:
        ac[p] += 1
    elif s == 'WA' and wa[p] == 0:
        wa[p] += 1
print(ac.count(1), wa.count(1))
# Judge status: Accepted
arr1 = input().split()
n,x = int(arr1[0]),int(arr1[1])

arr2 = input().split()

d = 0
count = 1
for i in range(1, n + 1):
  d += int(arr2[i-1])
  if d <= x:
    count +=1
    
print(count)
# Judge status: Accepted
x=int(input())
for i in range(1,10**5):
    if x<=(i*(i+1))//2:
        print(i)
        break
# Judge status: Wrong Answer
N=int(input())
c=list(map(int,input().split()))
flag=0
for i in range(N):
    if c[i]%2==0:
        if c[i]%3==0 or c[i]%5==0:
            flag=1
        else:
            flag=0
            print("DENIED")
            exit(0)

if flag==1:
    print("APPROVED")
else:
    print("DENIED")
# Judge status: Accepted
s = input()

y = int(s[:2])
m = int(s[2:])
if 1 <= y <= 12 and 1 <= m <= 12:
    print("AMBIGUOUS")
elif 1 <= y <= 12:
    print("MMYY")
elif 1 <= m <= 12:
    print("YYMM")
else:
    print("NA")
# Judge status: Accepted
import heapq

X, Y, A, B, C = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))
P.sort(reverse=True)
Q.sort(reverse=True)
P = sorted(P[:X])
Q = sorted(Q[:Y])
R.sort()
while R and (P[0] < R[-1] or Q[0] < R[-1]):
    if P[0] < Q[0]:
        heapq.heappush(P, R.pop())
        heapq.heappop(P)
    else:
        heapq.heappush(Q, R.pop())
        heapq.heappop(Q)
print(sum(P) + sum(Q))
# Judge status: Wrong Answer
s = input()

while s!="":
    if s[-5:]=="dream" or s[-5:]=="erase":
        s = s[:-5]
    elif s[-6:]=="dreamer" or s[-6:]=="eraser":
        s = s[:-6]
    else:
        print("NO")
        exit()
print("YES")
# Judge status: Accepted
n, a, b = map(int, input().split())
cnt = 0
for i in range(1, n+1):
    if a <= sum(list(map(int, list(str(i))))) <= b:
        cnt += i
print(cnt)
# Judge status: Accepted
def main():
    S = input()

    if "A" in S and "B" in S:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()
# Judge status: Accepted
import math
a,b,c=map(int,input().split())
eps = 0.00000000000001
if 4*a*b<(c-a-b)**2 and (c-a-b)>0:
	print('Yes')
else:
	print('No')
# Judge status: Accepted
import math
print(math.factorial(int(input())) % (10**9 + 7))
# Judge status: Accepted
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

if v <= w:
  print('NO')
else:
  diff_start = abs(b - a)
  diff_speed = v - w
  if diff_start <= diff_speed*t:
    print("YES")
  else:
    print("NO")
# Judge status: Wrong Answer
n = int(input())
if n < 105:
  print(0)
elif 105 <= n < 195:
  print(1)
else:
  print(2)
# Judge status: Accepted
inputted = list(map(int, input().split()))
A = inputted[0]
B = inputted[1]
K = inputted[2]

A2 = max([0, A - K])
B2 = max([0, B - max([0, K - A])])

answer = '{} {}'.format(A2, B2)

print(answer)
# Judge status: Wrong Answer
from sys import stdin


n = int(stdin.readline().strip())
a_lst = [int(x) for x in stdin.readline().strip().split()]

pos = len(a_lst) // 2
min_diff = 20202020201

while(True):
  left = sum(a_lst[:pos])
  right = sum(a_lst[pos:])
  diff = right - left
  
  if min_diff > abs(diff): min_diff = abs(diff)
  else: break
  
  if diff > 0: pos += 1
  elif diff < 0: pos -= 1
    
print(min_diff)
# Judge status: Wrong Answer
a, b = map(int, input().split())
print((a+b)//24)
# Judge status: Accepted
from collections import Counter
S = input()
N = len(S)

c = Counter(S)

def checkf(c1,c2,c3):
  return (c[c1] == c[c2] and c[c2] == c[c3]) or (c[c1] == c[c2] and c[c2] == c[c3]+1) or (c[c1] == c[c2]+1 and c[c2] == c[c3])

flg = checkf('a','b','c') or checkf('a','c','b') or checkf('b','a','c') or checkf('b','c','a') or checkf('c','a','b') or checkf('c','b','a')

print("YES" if flg else "NO")
# Judge status: Accepted
X=input()
n=100
for i in range(1,4000):
    n=int(n*1.01)
    if X<=n:
        print i
        quit()
# Judge status: Wrong Answer
a,b = map(int,input().split())

if (a%3 == 0 and b%3==0) or ((a+b)%3 == 0):
    print('Possible')
else:
    print('Impossible')
# Judge status: Accepted
x,n=map(int,input().split())
a=list(map(int,input().split()))
if n==0:
  ans=x
else:
  ans=0
  for i in range(101):
    y=x-i
    if y not in a:
      ans=y
      break
    z=x+i
    if z not in a:
      ans=z
      break
print(ans)
# Judge status: Wrong Answer
N, K = map(int, input().split())
ans = 0
for i in range(1, N+1):
    now = i
    mul = 0
    while now <= K:
        now *= 2
        mul += 1
    ans += (1/N)*(1+0.5**mul)
print(ans-1)
# Judge status: Wrong Answer
a,b=map(int,input().split())
if a>12:print(b)
elif 4<a<13:print(b/2)
else:print(0)
# Judge status: Wrong Answer
N =int(input())
lst = []
while N > 0:
    lst.append(N%10)
    N //= 10 
lst.reverse()

ans = sum(lst)

if ans % 9 == 0:
  print("yes")
else:
        print("No")
# Judge status: Wrong Answer
import math
N,M=(int(x) for x in input().split())
a=[0]*(N+1)
b=[0]*(N+1)
c=0
v=0
i=0

for i in range(N):
    A,B=(int(x) for x in input().split())
    a[i]=A
    b[i]=B
v = max(a)
#ソート開始
b.sort(reverse=True)
#ソート終了
#print(i,b[i],v,M,N)
i=0
for i in b:
    if i>=v:
        c+=1
        M-=i
    else:break
if M>0:
    c+=math.ceil(M/v)
print(c)
# Judge status: Accepted
N,M=[int(s) for s in input().split()]
if N%2==1:
  a=1
  b=N-1
  for i in range(M):
    print(*[a,b])
    a+=1
    b-=1
else:
  x=(N+2)//4
  a=1
  b=N-1
  for i in range(min([M,x-1])):
    print(*[a,b])
    a+=1
    b-=1
  a+=1
  for i in range(min([M-x+1,N//2-x])):
    print(*[a,b])
    a+=1
    b-=1
# Judge status: Accepted
x, y = map(int, input().split())
ans = 0
x2 = -x
y2 = -y
L = [y - x, y - x2, y2 - x, y2 - x2]
Labs = [abs(y - x), abs(y - x2), abs(y2 - x), abs(y2 - x2)]
ans += min(Labs)
i = L.index(min(Labs))
if i == 1 or i == 2:
    ans += 1
elif i == 3:
    ans += 2
print(ans)
# Judge status: Accepted
def resolve():
    '''
    code here
    '''
    import collections
    N = int(input())
    D = [int(item) for item in input().split()]
    d_dict = collections.Counter(D)

    cnt = 0
    if D[0] != 0:
        pass
    else:
        cnt = 1
        for i in D[1:]:
            cnt *= d_dict[i-1]
            cnt %= 998244353


    print(cnt % 998244353)

if __name__ == "__main__":
    resolve()
# Judge status: Accepted
a,b,c=map(str,input().split())
print(a[0]+b[0]+c[0])
# Judge status: Accepted
import math
N = int(input())
n = N
amari = 0
for i in range (len(str(N))):
  amari += n % 10
  n = math.floor(n / 10)
if amari == 1:
  print(10)
else:
  print(amari)
# Judge status: Accepted
import math
h,a = map(int,input().split())
print(math.ceil(h/a))
# Judge status: Accepted
x, y = map(int, input().split())
ans = 10**9 + 10
if x == y:
    ans = 0
else:
    #1
    ans1 = y-x
    ans2 = (-y)-(-x) + 2
    ans3 = y-(-x) + 1
    ans4 = (-y)-x + 1
    if ans1 > 0:
        ans = min(ans, ans1)
    if ans2 > 0:
        ans = min(ans, ans2)
    if ans3 > 0:
        ans = min(ans, ans3)
    if ans4 > 0:
        ans = min(ans, ans4)

print(ans)
# Judge status: Wrong Answer
N = int(input())
d = list(map(int, input().split()))
d = sorted(d)
cnt = 0
for i in range(d[0], d[N-1]):
    if d[N//2-1] < i <= d[N//2]:
        cnt += 1
print(cnt)
# Judge status: Accepted
n, d = map(int, input().split())
x = []
for i in range(n):
    x.append(list(map(int, input().split())))
ans = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        s = 0
        for k in range(d):
            s += (x[i][k] - x[j][k]) ** 2
        s **= 0.5
        if s.is_integer() == True:
            ans += 1
print(ans)
# Judge status: Wrong Answer
# Count median
N=int(input())
m=[]
M=[]
for i in range(N):
    x,y=map(int,input().split())
    m.append(x)
    M.append(y)
m.sort()
M.sort(reverse=True)
if N%2!=0:
    mini=m[N//2]
    maxi=M[-N//2]
    print(maxi-mini+1)
else:
    mini=m[N//2-1]
    maxi=M[-N//2]
    print((maxi-mini)*2+1)
# Judge status: Accepted
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# 問題：https://atcoder.jp/contests/abc135/tasks/abc135_c

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

f1 = min(a[0], b[0])
f2 = min(a[1], b[0] - f1)
res = f1 + f2
for i in range(1, n):
    f1 = min(a[i] - f2, b[i])
    f2 = min(a[i+1], b[i] - f1)
    res += f1 + f2

print(res)
# Judge status: Accepted
a, b, c, d = (int (i) for i in input().split())

if abs(a - c) <= d:
    print("Yes")
elif (abs(a - b) <= d) and (abs(b - c) <= d):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
a,b,c,k=map(int,input().split())
if k%2==0:
    ans=a-b
else:
    ans=b-a
print(ans)
# Judge status: Wrong Answer
s = input()
T = input()

dc = {}
for i, t in enumerate(T):
    if t in dc and dc[t] != s[i]:
        print("No")
        exit()
    else:
        dc[t] = s[i]
else:
    print("Yes")
# Judge status: Accepted
import fractions
from functools import reduce


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


def lcm_list(n):
    return reduce(lcm, n)


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

mod = 10 ** 9 + 7

L = lcm_list(a)
ans = 0
for i in a:
    ans += L // i

print(ans % mod)
# Judge status: Wrong Answer
from sys import stdin
N = int(stdin.readline().rstrip())
list = [int(x) for x in stdin.readline().rstrip().split()]
Q = int(stdin.readline().rstrip())
#print(1 in list)
for i in range(Q):
  s, t = [int(x) for x in stdin.readline().rstrip().split()]
  if s in list:
    sum = 0
    for j in range(len(list)):
      if list[j] == s:
        list[j] = t
      sum += list[j]
  print(sum)
# Judge status: Accepted
X,A,B=input().split()
numbers=[]
N=int(X)
 
def digitsum(n):
    s=str(n)
    array=list(map(int,s))
    return sum(array)
 
 
 
for num in range(1,N+1):
    if int(A)<=int(digitsum(num)) and int(digitsum(num))<=int(B):
        numbers.append(num)
    else:
        continue
 
print(sum(numbers))
# Judge status: Wrong Answer
import math

N = int(input())
T = [int(input()) for i in range(N)]
num = 1
for i in range(N - 1):
    cnt = (T[i] * T[i+1]) // math.gcd(T[i], T[i+1])
    num = (num * cnt) // math.gcd(num, cnt)

print(num)
# Judge status: Wrong Answer
d, n = map(int, input().split())
print(n * 100 ** d) if n < 100 else print((n + 1) * 100 **d)
# Judge status: Accepted
A, B, X = map(int, input().split())
print("YES" if 0 <= X-A <= B else "NO")
# Judge status: Wrong Answer
input = open(0).readline
s = {}
s['A'] = list(input().strip())
s['B'] = list(input().strip())
s['C'] = list(input().strip())

play_order = {'A':'B', 'B':'C', 'C':'A'}

def play(player):
    
    if  len(s[player]) == []:
        play(play_order[player])
    
    next_play = s[player].pop()
    if len(s[player]) == 0:
        print(player)
        return player
    #print(next_play)
    play(next_play.upper())
        
play('A')
# Judge status: Wrong Answer
if input() in '9':
  print('Yes')
else:print('No')
# Judge status: Accepted
a,b = input().split()
ab = int(a+b)
for i in range(int(ab//(1/2))+1):
         if i * i == ab:
                  print("Yes")
                  exit()
print("No")
# Judge status: Wrong Answer
N, M, X, Y = map(int, input().split())
x = sorted(list(map(int, input().split())))
y = sorted(list(map(int, input().split())))

flag = True

if y[0] < x[-1]:
    flag = False

if flag:
    print("No War")
else:
    print("War")
# Judge status: Accepted
n=int(input())

x=int(n/1.08)

if int(x*1.08)==n:
    print(x)
elif int((x+1)*1.08)==n:
    print(x+1)
else:
    print(':(')
# Judge status: Accepted
n,k=map(int,input().split())
p=list(map(int,input().split()))
P=sorted(p)
l=[]
cnt=0
for i in P:
  cnt+=1
  l.append(i)
  if cnt==k:
    break
print(sum(l))
# Judge status: Accepted
import sys

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

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

t1 = L - (L // 2019) * 2019
t2 = R - (L // 2019) * 2019
temp = 0
min_temp = 2019

if R - L >= 2019:
    print("0")
else:
    for i in range(t1, t2):
        for j in range(i + 1, t2 + 1):
            temp = (i * j) % 2019
            if temp < min_temp:
                min_temp = temp

    print(min_temp)
# Judge status: Accepted
n,m=map(int,input().split())
ans=0
now=n
while now<=m:
    ans+=1
    now*=2
print(ans)
# Judge status: Wrong Answer
n = int(input())
xy = []
for i in range(n):
    l = list(map(int, input().split()))
    xy.append(l[0]+l[1])
print(max(xy)-min(xy))
# Judge status: Wrong Answer
y1_list = list(map(int,input().split()))
y2_list = list(map(int,input().split()))
y3_list = list(map(int,input().split()))
 
a1 = list()
a2 = list()

for i in range(3):
    a1.append(y1_list[i] - y2_list[i])
    a2.append(y2_list[i] - y3_list[i])
    
if a1[0] == a1[1] and a1[2] == a1[0]:
    if a2[0] == a1[1] and a2[2] == a1[0]:
        print("Yes")
        
    else:
        print("No")
else:
    print("Mo")
# Judge status: Accepted
s = input()
ans = []

for i in s:
    if i=='B':
        if ans != []:
            ans.pop(-1)
    else:
        ans.append(i)
print(''.join(ans))
# Judge status: Accepted
# B
n,x = map(int, input().split())
d = 0
count = 1
l = list(map(int, input().split()))
for i in range(n):
    d += l[i]
    if d <= x:
        count+=1
print(count)
# Judge status: Wrong Answer
N, A, B = map(int, input().split())

ans = 0

if abs(B-A) % 2 == 0:
    ans = abs(B-A) // 2

else:
    if B > A:
        ans = min(N-A, B-1)
    if A > B:
        ans = min(N-B, A-1)


print(ans)
# Judge status: Accepted
S=list(input() for i in range(3))
i=0
while True:
    if S[i]=='':
        print(chr(i+65))
        exit()
    c=S[i][0]
    S[i]=S[i][1:]
    i=ord(c)-97
# Judge status: Wrong Answer
from decimal import Decimal
a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())

if a==b:
    print("YES")
    exit()
elif v==w:
    print("NO")
    exit()
a=abs(b-a)%abs(v-w)
atai = Decimal(str(a))
if atai==0:
    for i in range(1,t+1):
        if i == Decimal(abs(b-a))/Decimal(abs(v-w)):
            print("YES")
            exit()
    print("NO")
# Judge status: Accepted
N, K = map(int, input().split())
x = []
for i in range(N):
    a, b = map(int, input().split())
    x.append([a, b])

x.sort(key=lambda x: x[0])

c = 0
for a, b in x:
    c += b
    if K <= c:
        print(a)
        exit()
# Judge status: Accepted
D, T, S = map(int, input().split())


if D / S > T:
    print("No")
else:
    print("Yes")
# Judge status: Accepted
a=input().split()
N=int(a[0])
M=int(a[1])
H=[int(x) for x in input().split()]
way=[]
for i in range(M):
    way.append([int(x) for x in input().split()])

dic={}
for i in range(N):
    dic[i]=set()

for h in way:
    dic[h[0]-1].add(h[1]-1)
    dic[h[1]-1].add(h[0]-1)
    

print(sum(all([H[i]>H[hs] for hs in dic[i]])for i in range(N)))
# Judge status: Wrong Answer
N = int(input())

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

arr.sort()
cnt = 0
num = 1

a = arr[0]

for i in range(1,N):
  if arr[i] == a:
    num += 1
  else:
    num = 1
    a = arr[i]
    if num % 2 == 1:
      cnt += 1
print(int(cnt))
# Judge status: Accepted
x,y=map(int,input().split())
if x%y!=0:
    print(x)
else:
    print(-1)
# Judge status: Wrong Answer
import sys

def main():

	S = 0
	N,M = map(int, input().split())
	Lists = list(map(int, input().split()))
	
	count = 0
	
	for List in Lists:
		S += List
	
	
	print(N-S)
	
if __name__ == "__main__":
    main()
# Judge status: Accepted
N, A, B = map(int, input().split())
C = input()
D = [C[i:i+1] for i in range(N)]
AA = 0
BB = 0
for i in(D):
  if i == 'c':
    print('No')
  elif i =='a' and A+B > AA+BB:
    print('Yes')
    AA += 1
  elif i =='b' and A+B > AA+BB and BB < B:
    print('Yes')
    BB += 1
  else:
    print('No')
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))
s = []
for i in a:
    s.append(i)
    s.reverse()
print(s)
# Judge status: Accepted
n = int(input())
a = [int(x) for x in input().split()]

sm = 0
for x in a:
    sm ^= x

ans = [a[i]^sm for i in range(n)]

print(*ans)
# Judge status: Accepted
s =input()
print( ["Sunny","Cloudy","Rainy"][( ["Sunny","Cloudy","Rainy"].index(s)+1)%3])
# Judge status: Accepted
import sys
from operator import itemgetter

read = sys.stdin.read

N, M, *PY = map(int, read().split())
P = PY[::2]
Y = PY[1::2]

P, Y, I = zip(*sorted(zip(P, Y, range(M)), key=itemgetter(0, 1)))
P = list(map(str, P))
answer = []
prev_p = ''
n = 0
for p, i in zip(P, I):
    if prev_p == p:
        n += 1
    else:
        prev_p = p
        n = 1
    answer.append((p.zfill(6) + str(n).zfill(6), i))

answer.sort(key=itemgetter(1))
answer = [i for i, _ in answer]
print('\n'.join(answer))
# Judge status: Accepted
def main():
    N = int(input())
    A = list(map(int, input().split()))
    limit = pow(10, 18)
    A.sort()
    ans = 1
    if A[0] == 0:
        print(0)
    else:
        for a in A:
            ans *= a
            if ans > limit:
                print(-1)
                break
        else:
            print(ans)


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
cd = [list(map(int, input().split())) for _ in range(m)]
for i in range(n):
    seq_min = 1e8
    ans = -1
    for j in range(m):
        seq = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
        if seq_min > seq:
            seq_min = seq
            ans = j
    print(ans + 1)
# Judge status: Wrong Answer
N = int(input())

for i in range(1, 10):
    if N % i == 0:
        print("Yes")
        exit()
print("No")
# Judge status: Wrong Answer
l = int(input())

print((l**3)/9)
# Judge status: Wrong Answer
H,W = map(int,input().split())
if H % 2 == 1 and W % 2 ==1:
  print((H*W+1)/2)
else:
  print((H*W)/2)
# Judge status: Accepted
x = int(input())
A=[]
i=1
while i*i<=x:
  if x%i==0:
    A += [i, x//i]
  i += 1
for j in A:
  c= j//2
  a = c
  while a**5-(a-j)**5 < x:
    a +=1
  else:
    if a**5-(a-j)**5 == x:
      print(a,a-j)
      break
# Judge status: Accepted
a, b, c = map(int, input().split())
print("YES" if b-a==c-b else "NO")
# Judge status: Wrong Answer
x,y,a,b,c = (int(i_x) for i_x in input().split())

allredapple = input().split()
allgreenapple = input().split()
allnonapple =input().split()

allredapple.sort(reverse=True)
allgreenapple.sort(reverse=True)
allnonapple.sort(reverse=True)


zenalist = allredapple[:x] + allgreenapple[:y]
zenalist.sort(reverse=True)

for i in range(len(allnonapple)):
  for k in range(len(zenalist)):
    if int(zenalist[k]) < int(allnonapple[i]):
      zenalist[k] = allnonapple[i]
      break

anser = 0      
for i in range(len(zenalist)):
  anser += int(zenalist[i])

print(anser)
# Judge status: Wrong Answer
N, Y = map(int, input().split())

def main():
  if Y % 1000 != 0:
    print("-1 -1 -1")
    return
  cnt = Y // 1000
  if 10000 * cnt < N:
    print("-1 -1 -1")
    return
  for i in range(N):
    for j in range(N):
      for k in range(N):
        if i + j + k != N:
          continue
        if Y == 10000 * i + 5000 * j + 1000 * k:
          print("%i %i %i".format(i, j, k))

if __name__ == "__main__":
  main()
# Judge status: Accepted
from collections import Counter

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

over4 = []
over2 = []

for k, v in c.items():
    if v >= 4:
        over4.append(k)
    elif v >= 2:
        over2.append(k)

over4.sort(reverse=True)
over2.sort(reverse=True)

x, y, z = 0, 0, 0
if len(over4) > 0:
    x = over4[0] ** 2
if len(over2) >= 2:
    y = over2[0] * over2[1]
if len(over4) > 0 and len(over2) > 0:
    z = over4[0] * over2[0]

print(max(x, y, z))