peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
N = int(input())

i = int(N ** (1/2))
ans = 10 **13

while i > 0:
  if N % i == 0:
    ans = min(ans, i + N // i -2)
  i -= 1


print(ans)
# Judge status: Wrong Answer
x=input()
arr="abcdefghijklmnopqrstuvwxyz"
arr[arr.index(x)+1]
# Judge status: Accepted
import math
import itertools

N, D = [int(n) for n in input().split()]
X = []
for i in range(N):
    X.append([int(m) for m in input().split()])

def get_distance(p1, p2):
    d2 = 0
    for i in range(D):
        d2 += (p1[i] - p2[i])**2
    return math.sqrt(d2)

count = 0
for i, j in itertools.combinations(range(N), 2):
    if get_distance(X[i], X[j]).is_integer():
        count += 1

print(count)
# Judge status: Wrong Answer
string = input()
 
if string[-1] != 's':
  new_string = string[0:] + 's'
if string[-1] == 's':
  new_string = string[0:-1] +'es'
 
print(new_string)
# Judge status: Accepted
n,m = map(int,input().split())
done = [0]*n
ans = [0]*n
for i in range(m):
  s,c = map(int,input().split())
  if done[s-1] != 0 and ans[s-1] != c:
    print(-1)
    exit()
  elif n != 1 and s == 1 and c == 0:
    print(-1)
    exit()
  else:
    done[s-1] = 1
    ans[s-1] = c
ans_f = str()
for j in ans:
  ans_f += str(j)
if n>1 and ans_f[0] == "0":
  print("1"+ans_f[1::])
else:
  print(ans_f)
# Judge status: Accepted
from collections import Counter

s = input()
t = input()

if sorted(Counter(s).values()) == sorted(Counter(t).values()):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N, K = map(int, input().split())
S = [0] * N
for _ in range(K):
  n = int(input())
  for a in [int(x) for x in input().split()]:
    S[a - 1] += 1
print(sum([1 for s in S if s == 0]))
# Judge status: Wrong Answer
a, b = map(int, input().split())
num = 1
ans = 0
while num < b:
    num += a
    ans += 1
print(ans)
# Judge status: Accepted
n=int(input())
s=input()
i,j=0,len(s)-1
ans=0
while(i<=j):
	if(s[j]=='W'):
		j-=1
	elif(s[i]=='R'):
		i+=1
	else:
		ans+=1
		i+=1
		j-=1
print(ans)
# Judge status: Wrong Answer
N, T = map(int, input().split())

res = 10 ** 9
for _ in range(N):
    c, t = map(int, input().split())
    if t <= T:
        res = min(res, c)

if res <= T:
    print(res)
else:
    print("TLE")
# Judge status: Accepted
def cal_cost(co, h, i, j):
    return co + abs(h[i]-h[j])

n, k = map(int, input().split())
h = [int(i) for i in input().split(" ")]
lis = [0 for i in range(n)]
for i in range(1, n):
    a = min([cal_cost(lis[i-j], h, i-j, i) for j in range(1, k+1) if j<=i])
    lis[i] = a
print(lis[-1])
# Judge status: Accepted
N,M,K = [int(hoge) for hoge in input().split()]
ans = "No"
for n in range(N+1):
    for m in range(M+1):
        if m*(N-n) +n*(M-m)  == K:
            ans = "Yes"
print(ans)
# Judge status: Accepted
n, m = map(int, input().split())

n1 = n - 1
m1 = m - 1

res = int((n * n1) / 2 + (m * m1) / 2)

print(res)
# Judge status: Accepted
N,W=map(int,input().split())
w=[]
v=[]
for i in range(N):
  w_,v_=map(int,input().split())
  w.append(w_)
  v.append(v_)
  
dp=[[0]*(W+1) for i in range(N+1)]
for i in range(N):
  for j in range(W+1):
    dp[i+1][j]=max(dp[i+1][j],dp[i][j])
    if j+w[i] <=W:
      dp[i+1][j+w[i]]=max(dp[i+1][j+w[i]],dp[i][j]+v[i])

print(dp[N][W])
#print(dp)
# Judge status: Accepted
d=int(input())
c=list(map(int, input().split()))
s=[list(map(int,input().split())) for _ in range(d)]

from random import randint
for i in range(d):
    print(c.index(max(c))+1)
# Judge status: Wrong Answer
n=int(input())
sum=n*(n+1)/2
print(sum)
# Judge status: Accepted
import math
a, b, h, m = map(int, input().split())
H = 30 * h + 0.5 * m
M = 6 * m
angle = abs(H - M)

ans = a**2 + b**2 - (2 * a * b * math.cos(math.radians(angle)))
print(math.sqrt(ans))
# Judge status: Accepted
import numpy as np
D = int(input())
c = list(map(int, input().split()))
s = []
for i in range(D):
  tmp = list(map(int, input().split()))
  s.append(tmp)

for i in range(D):
  val_max = 0
  idx_max = 0
  for j in range(26):
    if val_max < s[i][j]:
      val_max = s[i][j]
      idx_max = j+1
  print(idx_max)
# Judge status: Wrong Answer
R = int(input())

print(2 * 3.14159265)
# Judge status: Wrong Answer
N=int(input())
count=0
S=""
for i in range(1,N-1):   
    S=len(str(i))
    if S%2!=0:
           count=count+1
print(count)
# Judge status: Wrong Answer
import random
a=input()
kekka=['Yes','No']
print(random.choice(kekka))
# Judge status: Wrong Answer
C=input()
CN=ord(C)
print(chr((CN)+1))
print(C+" is followed by "+chr((CN)+1)+".")
# Judge status: Accepted
import math

n, m = map(int, input().split(" "))

start = 1
end = n

wq = n // 4
for i in range(m):
    if i == wq and n % 2 == 0:
        start += 1
    print(start, end)
    start += 1
    end -= 1
# Judge status: Wrong Answer
A,B = map(int,input().split())

if B == 1:
  print(0)
  exit()

if B <= A:
  print(1)
  exit()

B -= A
ans = 1

while B >= 0:
  B -= (A - 1)
  ans += 1
  
print(ans)
exit()
# Judge status: Accepted
a,b,c=map(int,input().split())
if a<c<b or b<c<a:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
N = int(input())
print((int(N**0.5))**2)
# Judge status: Accepted
from itertools import accumulate
from bisect import bisect_right
n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A = list(filter(lambda x: x <= k, accumulate(A)))
B = list(filter(lambda x: x <= k, accumulate(B)))
ans = 0
for i, a in enumerate(A):
    j = bisect_right(B, k-a)
    ans = max(ans, i+j+1)
ans = max(ans, len(B))
print(ans)
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
s=''
for i in range(n):
    if i%2==0:
        s=s+str(a[i])
    else:
        s=str(a[i])+s
if n%2==1:
    s=s[::-1]
print(' '.join(s))
# Judge status: Accepted
N=input()

dp0=[0]*(len(N)+1)
dp1=[0]*(len(N)+1)
dp1[0]=1

for i in range(len(N)):
    n=int(N[i])
    dp0[i+1]=min(dp0[i]+n, dp1[i]+(10-n))
    n+=1
    dp1[i+1]=min(dp0[i]+n, dp1[i]+(10-n))

#print(dp0)
#print(dp1)
print(dp0[-1])
# Judge status: Accepted
n=int(input())
c=[]
s=[]
f=[]
for i in range(n-1):
    a,b,d=map(int,input().split())
    c.append(a)
    s.append(b)
    f.append(d)

for i in range(n-1):
    count=0
    for j in range(i,n-1):
        if count<=s[j]:
            count=s[j]
        else:
            if (count-s[j])%f[j]!=0:
                count+=f[j]-((count-s[j])%f[j])
        count+=c[j]
    print(count)

print(0)
# Judge status: Wrong Answer
import sys
import numpy as np
import math
import collections
import copy
import decimal
from collections import deque 
from functools import reduce
from itertools import product
from itertools import combinations

N = int(input())
An = list(map(int, input().split()))
An_s = collections.Counter(An)
total = 0
for k in An_s:
    total += k
tt = sum(An)
ans = 0
for A, v in An_s.items():
    if v == 1:
        At = A * (tt-A)
    else:
        At = A * (total-A)*v
#     print(A, v, total, At, ans)
    ans = (ans+At) % (10**9+7)
#     print(ans)
print(ans//2)
# Judge status: Wrong Answer
n = int(input())
p = [int(i) for i in input().split()]
x = p.copy()
x.sort()
pma = max(p)
pmi = min(p)
p[0] = pmi
p[-1] = pma
if x == p:
    print('YES')
else:
    print("NO")
# Judge status: Accepted
W,H,x,y=map(int,input().strip().split())

a=W*H/2
if x==W/2 and y==H/2:
    b=1
else:
    b=0

print(str(a)+" "+str(b))
# Judge status: Accepted
r, g, b = map(int, input().split())
num = r * 100 + g * 10 + b
if (num % 4 == 0):
  print('YES')
else:
  print('NO')
# Judge status: Accepted
s = input()

for i in range(len(s)):
    for j in range(len(s)):
        if i != j and s[i] == s[j]:
            print("no")
            exit()

print("yes")
# Judge status: Accepted
N = int(input())
M = 10**9 + 7

if N < 3:
    print(0)
elif N < 6:
    print(1)
else:
    dp = [0] * (N + 1)
    dp[3] = 1
    dp[4] = 1
    dp[5] = 1
    P = dp[3]
    for i in range(6, N + 1):
        dp[i] = (P + 1) % M
        P = (P + dp[i - 2]) % M
    print(dp[-1] % M)
# Judge status: Accepted
s = list(input())
if s == list(reversed(s)) and s[:len(s)//2] == list(reversed(s[:len(s)//2])):
  print("Yes")
else:
  print("No")
# Judge status: Accepted
if (int(input()))%9 == 0:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
a,b=map(str,input().split())
c=int(a+b)
sq = [i*i for i in range(1,101)]
if c in sq: print('Yes')
else: print('No')
# Judge status: Accepted
s = input()

if s=="abc" or s=="acb" or s=="bac" or s== "bca" or s=="cba" or s=="cab":
  print("Yes")
else:
  print("No")
# Judge status: Accepted
import math
h,m,h2,m2,k = map(int,input().split())
all = h2*60+m2 - (h*60+m)
print(all - k)
# Judge status: Wrong Answer
N, K = map( int, input().split() )

# ユークリッドの互除法
# a = b * q + r 
# b = b'* r + r' ...

a = N
b = K
if a < b:
  r = b - a
else:
  r = a % b
ret = 0
while r != 0:
  a = b
  b = r
  r = a % b
  if r == 0:
    break
  ret = r
print( ret )
# Judge status: Wrong Answer
N = int(input())
lst = []
for i in range(N):
    A,B = map(int,input().split())
    lst.append([B,A])
    
lst.sort()  
left = lst[0][0] - lst[0][1]

for i in range(1,N):
    left = left + (lst[i][0] - lst[i-1][0])
    left -= lst[i][1]
    if left < 0:
        print("No")
        exit()
print("Yes")
# Judge status: Accepted
a, b, k = map(int, input().split())

if b - a < k*2:
    for j in [i for i in range(a, b+1)]:
        print(j)
else:
    for j in [i for i in range(a, a+k)]:
        print(j)
    for j in [i for i in range(b-k+1, b+1)]:
        print(j)
# Judge status: Accepted
def main(a: int, b: int, c: int):
    ls = []

    for i in range(a, b * a + 1, a):
        if i % b in ls:
            break

        ls.append(i % b)

    if c in ls:
        print("YES")
    else:
        print("NO")


if __name__ == "__main__":
    a, b, c = map(int, input().split())

    main(a, b, c)
# Judge status: Accepted
n=int(input())
odd=0
even=0
for i in range(1,n+1):
  if i%2==0:
    even+=1
  else:
    odd+=1
print(even*odd)
# Judge status: Accepted
n,m=map(int,input().split())
if n*2<m:
  print((2*n+m)//4)
else:
  print(m//2)
# Judge status: Wrong Answer
import math
A,B,H,M = map(int,input().split())

m = 0
if M != 0:
    m = M / 5

if H == 0:
    h = 12
else:
    h = H*30
if m == 0:
    mm = 360
else:
    mm = m*30

if h >= mm:
    rad = (h+0.5*M)-(mm)
else:
    rad = (mm)-(h+0.5*M)

ans = A**2 + B**2 - 2*A*B*(math.cos(math.radians(rad)))
print(ans**0.5)
# Judge status: Accepted
import sys
import math
def input(): return sys.stdin.readline().rstrip()
def main():
    x = int(input())
    xx = x
    ans = 1
    while xx%360 != 0:
        xx += x
        ans += 1
    print(ans )

if __name__=='__main__':
    main()
# Judge status: Accepted
import sys
import numpy as np
input = sys.stdin.readline

N,M,X = list(map(int,input().split()))
CA = [ list(map(int,input().split())) for _ in range(N)]
bit = 2**N
cost = float('inf')

for bi in range(1,bit):
    tmp=[]
    for i in range(N):
        if bi & 1<<i:
            tmp.append(CA[i-1])
    tmp = np.array(tmp)        
    a = sum(tmp)
    if all( [a[j]>=X for j in range(1,M+1)]):
        cost = min(cost,a[0])
print( -1 if cost == float('inf') else cost)
# Judge status: Accepted
s=input()
n=len(s)+1
l=[0]*n
r=[0]*n
for i in range(n-1):
    if s[i]=='<': 
      l[i+1]=l[i]+1
    if s[n-2-i]=='>': 
      r[n-2-i]=r[n-1-i]+1
ans=0
for i in range(n):
  ans+=max(l[i],r[i])
print(ans)
# Judge status: Accepted
def main():
    N = int(input())
    A = list(map(int, input().split()))

    if 0 in A:
        print(0)
        return

    anser = 1
    for a in A:
        anser *= a
        if anser > 1000000000000000000:
            print(-1)
            return

    print(anser)

main()
# Judge status: Accepted
l, r, d = map(int, input().split())
cnt = 0
for i in range(l, r + 1):
    cnt += (i % d == 0)
print(cnt)
# Judge status: Accepted
alph = [chr(i) for i in range(97, 97+26)]

s = input()
s_li = set(sorted(list(s)))

for v in alph:
    if v not in s_li:
        print(v)
        exit(0)
print('None')
# Judge status: Accepted
import sys
sys.setrecursionlimit(200000)
 
n = int(input())
 
h = [int(i) for i in input().split()]
 
d = {}
 
def dp(p):
  if p in d:
    return d[p]
  if p == n-1:
    return 0
  if p < n-2:
    m = min(dp(p+1)+abs(h[p]-h[p+1]), dp(p+2)+abs(h[p]-h[p+2]))
    d[p] = m
    return m
  if p == n-2:
    return dp(p+1)+abs(h[p]-h[p+1])

print(dp(0))
# Judge status: Accepted
A, B = map(int, input().split())
if 1 <= A and A<= 9 and 1 <= B and B<= 9:
    print(A*B)
else:
    print(-1)
# Judge status: Accepted
S = sorted(input())

if S[0]==S[1]==S[2]==S[3]:
  print("No")
elif S[0]==S[1] and S[2]==S[3]:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
X  = int ( input().strip() ) ;
print ( "No" if X < 30 else "Yes" ) ;
# Judge status: Accepted
n,k = map(int, input().split())
s = input()

k = k-1

for i in range(n):
  if i == k:
    x = s[i].lower()
    print(x,end="")
  else:
    print(s[i],end="")
# Judge status: Accepted
def main():
    import sys
    import math
    input = sys.stdin.buffer.readline
    n = int(input())
    A = list(map(int, input().split()))
    ans = 0
    node = 1
    max_node = sum(A)
    for i in range(n+1):
        ans += node
        max_node -= A[i]
        node = min(max_node,(node-A[i])*2)
        if node < 0:
            print(-1)
            exit(0)
    print(ans)


if __name__ == '__main__':
    main()
# Judge status: Accepted
import sys
input = sys.stdin.readline

# A - Range Product
a, b = map(int, input().split())

if a > 0:
	print('Positive')
elif b >= 0:
	print('Zero')
else:
	if b > 0:
		b == 0
	
	if (abs(a)-abs(b)+1) % 2 == 1:
		print('Negative')
	else:
		print('Positive')
# Judge status: Accepted
import math
N = int(input())
if N%27!=26 and N%27!=13:
  print(math.ceil(N/1.08))
else:
  print(':(')
# Judge status: Wrong Answer
S = "ARC" or "ABC"
if S == "ABC" :
  print("ARC")
if S == "ARC" :
  print("ABC")
# Judge status: Accepted
x, a, b = map(int, input().split())

if abs(x-a) < abs(x-b):
    print("A")
else:
    print("B")
# Judge status: Accepted
S=input()
if S=="AAA" or S=="BBB":
    print("No")
else: print("Yes")
# Judge status: Accepted
f=lambda:list(map(int,input().split()))
n,a,b,c=f()[0],f(),f(),f()
print(sum(b)+sum(c[a[i]-1] for i in range(n-1) if a[i+1]-a[i]==1))
# Judge status: Accepted
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N, M, X, Y = map(int, input().split())
XS = list(map(int, input().split())) + [X]
YS = list(map(int, input().split())) + [Y]

print("No War" if max(XS) < min(YS) else "War")
# Judge status: Wrong Answer
a, b = map(int, input().split())
c = min(a, b)
print(c)
for i in range(c, a * b + 1):
    if i % a == 0 and i % b == 0:
        print(i)
        exit()
# Judge status: Accepted
N=int(input())
x=[]
y=[]
for _ in range(N):
  a, b=map(int, input().split())
  x.append(a)
  y.append(b)

from math import factorial
from math import sqrt
ans=0

def d(x1, x2, y1, y2):
  return sqrt((x1-x2)**2+(y1-y2)**2)

num=factorial(N-1)*2
for i in range(N-1):
  for j in range(i+1,N):
    ans+=num*d(x[i],x[j],y[i],y[j])
print(ans/factorial(N))
# Judge status: Accepted
w, a, b = map(int, input().split())
if abs(a - b) < w:
    ans = 0
else:
    ans = abs(a - b) - w
print(ans)
# Judge status: Wrong Answer
l=list(map(str,input()))
print(2*(min(l.count(0),l.count(1))))
# Judge status: Accepted
S =input()

print('No' if 'L' in S[::2] or 'R' in S[1::2] else 'Yes')
# Judge status: Accepted
N = int(input())
W = [int(n) for n in input().split()]
W_ = [W[0]]

for i in range(1, N):
    W_.append(W_[-1] + W[i])
#print(W_)

d_min = 100000
for i in range(N):
    d = abs(2 * W_[i] - W_[-1])
    d_min = min(d_min, d)

print(d_min)
# Judge status: Accepted
L = [int(T) for T in input().split()]
print(['No','Yes'][sorted(L)[1]==L[2]])
# Judge status: Wrong Answer
import sys
N=int(input())
A=list(map(int,input().split()))
if A[0]>=1:
  print(-1)
  sys.exit()
ans=A[N]
left=1
P=[1 for i in range(N+1)]
for i in range(1,N+1):
  point=left*2
  P[i]=point
  if i!=N and point-A[i]<0:
    print(-1)
    sys.exit()
  if i==N and point-A[i]<0:
    print(-1)
    sys.exit()
  left=point-A[i]
root=A[N]
for i in range(N,0,-1):
  root=min(P[i-1],root+A[i-1])
  ans+=root
print(ans)
# Judge status: Wrong Answer
H,N=map(int,input().split())

sum = 0
1<=H<=10**9
1<=N<=10**4


import random

for i in range(1,N+1):
    attack = random.randint(1,10**4)
    print(attack)

    sum += attack

total = sum

if H - total <= 0:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Jan 12 22:19:09 2020

@author: nanasakiwataru
"""

C = input()
ans = chr(ord(C) + 1)
st = C + 'の次は' + ans + 'です。'
print(st)
# Judge status: Accepted
N, M = map(int, input().split())
num = [1]*(N+1)
red = [0]*(N+1)
red[1] = 1

for _ in range(1,M+1):
    x, y = map(int, input().split())
    if red[x]:
        red[y] = 1   
    num[x] = num[x]-1
    num[y] = num[y]+1
    if num[x]==0:
        red[x] = 0

ans = 0
for i in range(1,N+1):
    if red[i] == 1:
        ans+=1
print(ans)
# Judge status: Wrong Answer
import sys

N = int(input())


if N == 1:
    print(int(input()))
    sys.exit()

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

if len(A) == 1:
    print(0)
    sys.exit()

count = 1
A = sorted(A)
B = [A[0]]

for i in range(len(A)-1):
    Flag = True
    for j in B:
        if A[i+1] % j == 0:
            Flag = False
    if Flag == True:
        B.append(A[i+1])

print(len(B))
# Judge status: Accepted
s = input()
if s == 'RRR':
    print(3)
elif s == 'RRS' or s == 'SRR':
    print(2)
elif s == 'SSS':
    print(0)
else:
    print(1)
# Judge status: Accepted
q,h,s,d,n=map(int,open(0).read().split())
if n%2==0:
  print(min(8*q,4*h,2*s,d)*(n//2))
else:
  print(min(8*q,4*h,2*s,d)*(n//2)+min(4*q,2*h,s))
# Judge status: Wrong Answer
S = input()
if S == "Sunny":
    print ('cloudy')
elif S == "Cloudy" :
    print ('Rainy')
else :
    print ('Sunny')
# Judge status: Wrong Answer
N, K = map(int,input().split())
List_1 = sorted(list(map(int, input().split())), reverse=True)
K = K+1
ans = sum(List_1[:K])
# Judge status: Wrong Answer
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0

for a in range(A+1):
    if 500 * a > X:
        break
    for b in range(B+1):
        if 500 * b > X:
            break
        x = X - 500*a -100*b

        if x%50 == 0 and x >= 0:
            if x//50 <= C:
                ans += 1

print(ans)

#
# Judge status: Accepted
import re
a, b = [int(x) for x in input().split()]
s = input()
print("Yes" if re.search("\\d{{{}}}-\\d{{{}}}".format(a, b), s) is not None else "No")
# Judge status: Accepted
a, b = map(int, input().split())
print("Even" if a*b % 2 == 0 else "Odd")
# Judge status: Accepted

ans = float("inf")


def solve():

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

    if N % K:
        print(1)
    else:
        print(0)


if __name__ == "__main__":
    solve()
# Judge status: Accepted
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    import collections
    import bisect
    n,m = readInts()
    p = [[int(j) for j in input().split()] for i in range(m)]
    a = collections.defaultdict(list)
    for x,y in sorted(p):
        a[x] += [y]
    #print(a)
    for x,y in p:
        z = bisect.bisect_right(a[x],y)
        print("%06d%06d"%(x,z))



if __name__ == '__main__':
  main()
# Judge status: Accepted
A, B, C, D = map(int, input().split())
while 1:
    C -= B
    if C <= 0:
        print('Yes')
        exit()
    A -= D
    if A <= 0:
        print('No')
        exit()
# Judge status: Wrong Answer
n=int(input())
p=[3,5,7,11,13]
x=[]
for i in range(5):
	for j in range(i):
		for k in range(j):
			if n >= p[i]*p[j]*p[k]:
				x.append(i*j*k)
cnt=len(x)
if  135 <= n <189:
	cnt += 1
elif   n  <= 189:
	cnt += 2
else:
	pass
print(cnt)
# Judge status: Accepted
n = int(input())
s = input()

ans = s.count("R") * s.count("G") * s.count("B")

for i in range(n):
    for j in range(i+1, n):
        k = 2 * j - i
        if k >= n:
            break
        ans -= s[k] != s[i] != s[j] != s[k]

print(ans)
# Judge status: Wrong Answer
import collections
n = int(input())
l = map(int, input().split())
c = collections.Counter(l)
c = sorted(c.items(), key=lambda c:c[0], reverse=True)

ans = 1
cnt = 0

for key,val in c:
  if val>=2:
    ans*=key
    cnt+=1
  if cnt == 2:
    break
else:
  ans = 0
print(ans)
# Judge status: Wrong Answer
a, b = map(int, input().split())
preans = max(a*2-1,b*-1)
ans=max(preans,a+b)
print(ans)
# Judge status: Accepted
n, k = map(int, input().split())
d = list(map(str, input().split()))
possible = [str(i) for i in range(10) if str(i) not in d]
for i in range(n,10**5):
    for j in str(i):
        if j not in possible:
            break
    else:
        print(i)
        exit()
# Judge status: Accepted
import sys
from bisect import bisect_left, bisect_right

n = int(sys.stdin.buffer.readline())
a = list(map(int, sys.stdin.buffer.readline().split()))
b = list(map(int, sys.stdin.buffer.readline().split()))
c = list(map(int, sys.stdin.buffer.readline().split()))
a.sort()
b.sort()
c.sort()
ans = 0
for j in b:
    ans += (n - bisect_right(c, j))*bisect_left(a, j)
print(ans)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))
ans_l = [0]*n
for i in reversed(range(1,n)):
    if sum(ans_l[(i-i)::i])%2 != a[i]:
        ans_l[i] += 1
if sum(ans_l) != a[0]:
    ans_l[0] += 1
ans = []
for i in range(n):
    if ans_l[i]==1:
        ans.append(i+1)
print(len(ans))
if len(ans)>0:
    print(" ".join(map(str, ans)))
# Judge status: Wrong Answer
n = int(input())
A = list(map(int, input().split()))

l = [[] for i in range(n)]

for i in range(n):
    l[i] = [A[i], i+1]
print(l)
l.sort()
print(l)
ans = [0 for i in range(n)]

for i in range(n):
    ans[i] = l[i][1]

print(*ans)
# Judge status: Accepted
H = int(input())
x = [[float('inf')]*2 for i in range(H)]

for i in range(H):
    X, L = map(int, input().split())
    x[i][0] = X - L
    x[i][1] = X + L

from operator import itemgetter
sf = sorted(x, key=itemgetter(1))

ans = 0
last = float('inf')*-1

for i in range(H):
    if last <= sf[i][0]:
        ans += 1
        last = sf[i][1]

print(ans)
# Judge status: Accepted
import math

n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]

dis = []
for i in range(n-1):
    for j in range(i+1, n):
        dis.append(((xy[i][0]-xy[j][0])**2+(xy[i][1]-xy[j][1])**2)**(1/2))
print(2*math.factorial(n-1)*sum(dis)/(math.factorial(n)))
# Judge status: Wrong Answer
def gcd(a,b):
    r=1
    while r!=0:
        r=a%b
        a=b
        b=r
    return a
g=1
n = int(input())
t = [int(input()) for i in range(n)]
t1 = list(set(t))
n1 = len(t1)
for i in range(n1):
    g = gcd(g,t1[i])
ans = g
for i in range(n1):
    ans *= t1[i]//g
print(ans)
# Judge status: Accepted
n=int(input())
p=list(map(int,input().split()))
m=p[0]
total=0
for i in range(0,n):
  if m>=p[i]:
    m=p[i]
    total+=1
print(total)
# Judge status: Wrong Answer
N, M=map(int, input().split())
if N==M:
  print('YES')
else:
  print('NO')
# Judge status: Accepted
L, R, d = list(map(int, input().split()))

s = [i for i in range(L,R+1)]

ans = 0

for i in s:
    if i % d == 0:
        ans += 1

print(ans)
# Judge status: Accepted
import sys
x = int(input())
for a in range(-1000, 1000):
    for b in range(-1000, 1000):
        if a ** 5 - b ** 5 == x:
            print(a, b)
            sys.exit()
# Judge status: Accepted
N, x = map(int, input().split())
a = list(map(int, input().split()))
count = 0
maxcandy = 0
X = x

A = sorted(a)

for i in range(N):
    maxcandy += A[i]

for i in range(N):
    if x >= A[i]:
        x = x - A[i]
        count += 1
    else:
        break

if maxcandy < X:
    print(count-1)
else:
    print(count)
# Judge status: Accepted
a,b,c =map(int,input().split())
if b-a == c-b:
    print("YES")
else:
    print("NO")