Harryxun/stf_run huggingface dataset:
n, k = map(int, input().split())
a_list = list(map(int, input().split()))
a_list.sort()

import math


def cmb(n, r):
    o = math.factorial(n)
    u = math.factorial(r) * math.factorial(n - r)
    return o / u


max_val = 0
min_val = 0
val = int(cmb(n - 1, k - 1))
for i in range(n - k + 1):
    if i != 0:
        val = int(val * (n - i - k + 1) / (n - i))
    max_val = int(max_val + (((a_list[-(i + 1)]) * val))) % (10 ** 9 + 7)
    min_val = int(min_val + ((a_list[i]) * val)) % (10 ** 9 + 7)

print(int((max_val - min_val) % (10 ** 9 + 7)))

### FIXED CODE ###

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


mod = 10 ** 9 + 7
f_list = [1]
for i in range(1,n+1):
    f_list.append((f_list[-1] * i) % mod)
def comb(n,r):
    return f_list[n] * (pow(f_list[r], mod-2, mod) * pow(f_list[n-r], mod-2, mod) % mod) % mod


max_val = 0
min_val = 0
for i in range(n - k + 1):
    val = comb(n - i - 1, k - 1)
    max_val = (max_val + (((a_list[-(i + 1)]) * val))) % (10 ** 9 + 7)
    min_val = (min_val + ((a_list[i]) * val)) % (10 ** 9 + 7)

print(int((max_val - min_val) % (10 ** 9 + 7)))
s = list(input())
t = 700 + s.count(o) * 100
print(t)

### FIXED CODE ###

s = list(input())
t = 700 + s.count("o") * 100
print(t)
def main():
    N, X, M = map(int, input().split())
    NN = N
    li = []
    while X not in li and N != 0:
        li = li + [X]
        X = X ** 2 % M
        N -= 1
    
    if N == 0:
        print(sum(x for x in li))

    elif N != 0 and X in li:
        l = len(li)
        s = li.index(X)
        T = l - s
        q = (NN - s) // T
        r = (NN - s) % T
        print(sum(li[i] for i in range(s)) + sum(li[i] for i in range(s, len(li))) * q + sum(li[i] for i in range(s, s + r)))


main()

### FIXED CODE ###

S = input()
l = len(S)
if S[l-1] != 's':
    print(S + 's')
else:
    print(S + 'es')
N=int(input())

x = [0 for i in range(M)]
y = [0 for i in range(M)]

for i in range(N):
    X[i], Y[i], Z[i] = map(int, input().split())
import math
import numpy as np


def distance(x, y, i, j):
    d = math.sqrt((x[i] - x[j])**2 + (y[i] - y[j])**2)
    return d

da = np.zeros([N, N])
for i in range(N):
    for j in range(N):
        Da = distance(x, y, i, j)
        da[i][j] = Da
avg = da.sum() * math.factorial(N-1) / math.factorial(N)
print(avg)

### FIXED CODE ###

import math
N = int(input())
x = [0]*N
y = [0]*N
for i in range(N):
    x[i],y[i] = map(int,input().split())
at=[]
for i in range(N):
    for j in range(N):
        ea = math.sqrt((x[i] - x[j])**2 + (y[i] - y[j])**2)
        at.append(ea)
da = 0
for ag in at:
    da += ag
avg = da * math.factorial(N - 1) / math.factorial(N)
print(avg)
def cut(i, j, num):
  marked[i][j]=num
  if i>0 and cake[i-1][j]=="." and marked[i-1][j]==0:
    cut(i-1, j, num)
  if j>0 and cake[i][j-1]=="." and marked[i][j-1]==0:
    cut(i, j-1, num)
  if i<H-1 and cake[i+1][j]=="." and marked[i+1][j]==0:
    cut(i+1, j, num)
  if j<W-1 and cake[i][j+1]=="." and marked[i][j+1]==0:
    cut(i, j+1, num)

H, W, K=map(int, input().split())
cake=[input() for _ in range(H)]
marked=[[0 for _ in range(W)] for _ in range(H)]
mark=0
for i in range(H):
  for j in range(W):
    if cake[i][j]=="#":
      mark+=1
      cut(i, j, mark)
print(marked)

### FIXED CODE ###

from collections import deque

H, W, K=map(int, input().split())
cake=[input() for _ in range(H)]
rows_list=[]
upper=0
for i in range(H):
  for j in range(W):
    if cake[i][j]=="#":
      rows_list.append([upper, i])
      upper=i+1
      break
rows_list[-1][-1]=H-1
ans_list=[]
for rows in rows_list:
  for i in range(rows[0], rows[1]+1):
    left=0
    for j in range(W):
      if cake[i][j]=="#":
        ans_list.append([rows[0], rows[1], left, j])
        left=j+1
    if ans_list:
      ans_list[-1][-1]=W-1
ans=[[0 for _ in range(W)] for _ in range(H)]
key=1
for l in ans_list:
  for i in range(l[0], l[1]+1):
    for j in range(l[2], l[3]+1):
      ans[i][j]=key
  key+=1
for a in ans:
  print(*a)
s = input()
 print(s.count('+')-s.count('-'))

### FIXED CODE ###

s=input()
print(s.count('+')-s.count('-'))
d,n=map(int,input().split())
if n=100:
    print(100**d*101)
else:    
    print(100**d*n)

### FIXED CODE ###

d,n=map(int,input().split())
if n==100:
    print(pow(100,d)*101)
else:    
    print(pow(100,d)*n)
input = input().split(" ")
N = input[0]
L = input[1]

inputs = list()
for n in range(N):
  list.append(input())

inputs.sort()
answer = "".join(inputs)
print(answer)

### FIXED CODE ###

inputNL = input().split(" ")
N = int(inputNL[0])
L = int(inputNL[1])
 
inputs = []
for n in range(N):
  inputs.append(input())
 
inputs.sort()
answer = "".join(inputs)
print(answer)
N = int(input())
flag = False
for i in range(1,3500):
    for j in range(1,3500):
        if((N*i*j)%(4*i*j - N*i - N*j) == 0 and (4*i*j - N*i - N*j) > 0):
            w = int((N*i*j)%(4*i*j - N*i - N*j))
            h = i
            n = j
            flag = True
            break
    if flag:
        break

print(h,n,w)

### FIXED CODE ###

N = int(input())
flag = False
for i in range(1,3500):
    for j in range(1,3500):
        if((4*i*j - N*i - N*j) > 0 and (N*i*j)%(4*i*j - N*i - N*j) == 0):
            w = int((N*i*j)/(4*i*j - N*i - N*j))
            h = i
            n = j
            flag = True
            break
    if flag:
        break

print(h,n,w)
n = int(input())
A = list(map(int, input().split()))
q = int(input())
mi = map(int, input().split())

def solve(i, m):
    if (m == 0):
        return True
    if (i >= n):
        return False
    res = solve(i + 1, m) or solve(i + 1, m - A[i])
    return res

for i in mi:
    if solve(0, m):
        print("yes")
    else:
        print("no")

### FIXED CODE ###

n = int(input())
A = list(map(int, input().split()))
q = int(input())
mi = map(int, input().split())
t = {}

def solve(i, m):
    if (m == 0):
        return True
    if (i >= n):
        return False
    if (i,m) in t:
        return t[(i,m)]
    res = solve(i + 1, m) or solve(i + 1, m - A[i])
    t[(i,m)] = res
    return res

for m in mi:
    if solve(0, m):
        print("yes")
    else:
        print("no")
N, Q = map(int, input().split())
s = input()
td = []
for i in range(Q):
    td.append(input().split())
#print("td = {}".format(td))

llim = 0
rlim = N - 1
for t, d in reversed(td):
    if((s[llim] == t) and ("L" == d)):
        llim += 1
    elif(llim - 1 >= 0):
        if((s[llim - 1] == t) and ("R" == d)):
            llim -= 1
    if((s[rlim] == t) and ("R" == d)):
        rlim -= 1
    elif(rlim + 1 <= N - 1):
        if((s[rlim + 1] == t) and ("L" == d)):
            rlim += 1
#    print("td = {}, llim = {}, rlim = {}".format([t, d], llim, rlim))

print(str(max(0, rlim - llim + 1)))


### FIXED CODE ###

N, Q = map(int, input().split())
s = " " + input() + " "
td = []
for i in range(Q):
    td.append(input().split())
#print("td = {}".format(td))

llim = 0
rlim = N + 1
for t, d in reversed(td):
    if((s[llim + 1] == t) and ("L" == d)):
        llim += 1
    elif((s[llim] == t) and ("R" == d)):
        llim -= 1
    if((s[rlim - 1] == t) and ("R" == d)):
        rlim -= 1
    elif((s[rlim] == t) and ("L" == d)):
        rlim += 1
#    print("td = {}, llim = {}, rlim = {}".format([t, d], llim, rlim))

print(str(max(0, rlim - llim - 1)))
a, b = map(int, input().split())
print(b*2-a)

### FIXED CODE ###

a = int(input())
b = int(input())
print(b*2-a)
nums = [int(x) for x in input().split()]

sign = [1] * 4
for x in range(4):
    if nums[x] < 0:
        sign[x] = 0

result = min(nums[0:2]) * min(nums[2:])

if sum(sign) == 1:
    result = max(a[0:2]) * max(a[2:])

if sum(sign) == 2:
    if (sign[0] == 1 and sign[1]) or (sign[2] == 1 and sign[3] == 1):
        if sign[0] == 1:
             result = max(nums[0:2]) * min(nums[2:])
        elif sign[2] == 0:
             result = min(nums[0:2]) * max(nums[2:])

print(result)


### FIXED CODE ###

nums = [int(x) for x in input().split()]

sign = [0] * 4
for x in range(4):
    if nums[x] < 0:
        sign[x] = 1

result = min(nums[0:2]) * min(nums[2:])

if sum(sign) == 1 or sum(sign) == 0:
    result = max(nums[0:2]) * max(nums[2:])

if sum(sign) == 2:
    if (sign[0] == 1 and sign[1]) or (sign[2] == 1 and sign[3] == 1):
        if sign[0] == 1:
             result = max(nums[0:2]) * min(nums[2:])
        elif sign[2] == 1:
             result = min(nums[0:2]) * max(nums[2:])
    else:
        cur1 = nums[0] * nums[2]
        cur2 = nums[1] * nums[3]
        if abs(cur1) > abs(cur2):
            result = cur1
        else:
            result = cur2
print(result)
import math
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
b=[0]*n
b[n-2]=abs(a[n-1]-a[n-2])
for i in range(n-3,-1,-1):
    mini=math.inf
    for j in range(i+1,min(n,i+k+1)):
        x=abs(a[j]-a[i])+(b[j] if j<n-1 else b[n-1])
        mini=min(mini,x)
    b[i]=mini
print(b[0])

### FIXED CODE ###

import math
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
b=[0]*n
b[n-2]=abs(a[n-1]-a[n-2])
for i in range(n-3,-1,-1):
    c=[]
    for j in range(i+1,min(n,i+k+1)):
        c.append(abs(a[j]-a[i])+b[j])
    b[i]=min(c)
print(b[0])
n,m=map(int,input().split())
py=[list(map(int,input().split()))]
l=[1]*n
for i in range(m):
    py[i].append(i+1)
py.sort()
for i in range(m):
    py[i].append( str(py[i][0]).zfill(6) + str(l[py[i][0]-1]).zfill(6))
    l[py[i][0]-1]+=1
py.sort(key=lambda x:x[2])
for i in range(m):
    print(py[i][-1])

### FIXED CODE ###

n,m=map(int,input().split())
py=[list(map(int,input().split())) for _ in range(m)]
l=[1]*n
for i in range(m):
    py[i].append(i+1)
py.sort()
for i in range(m):
    py[i].append( str(py[i][0]).zfill(6) + str(l[py[i][0]-1]).zfill(6))
    l[py[i][0]-1]+=1
py.sort(key=lambda x:x[2])
for i in range(m):
    print(py[i][-1])
from sys import stdin


def fetch_one_line():
    return stdin.readline().rstrip()


def fetch_int_input():
    return [int(s) for s in fetch_one_line().split()]


def fetch_inputs(times):
    return [fetch_one_line() for _ in range(times)]


def fetch_int_inputs(times):
    return [[int(s) for s in fetch_one_line()] for _ in range(times)]

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

from math import gcd
a, b = fetch_int_input()
print(lcm(a, b))




### FIXED CODE ###

from sys import stdin


def fetch_one_line():
    return stdin.readline().rstrip()


def fetch_int_input():
    return [int(s) for s in fetch_one_line().split()]


def fetch_inputs(times):
    return [fetch_one_line() for _ in range(times)]


def fetch_int_inputs(times):
    return [[int(s) for s in fetch_one_line()] for _ in range(times)]

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

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

a, b = fetch_int_input()
print(lcm(a, b))
a=input()
b=input()

print a*a, b*b

### FIXED CODE ###

a, b = map(int, raw_input().split())
print a*b, (a+b)*2
S = list(input())
N = len(S)
ans = 999
for i in range(0, N - 3):  #1 2 3 4 5 6 7 #0 1 2 3 4 5 6
	num = S[i] * 100 + S[i + 1] * 10 + S[i + 2]
	ans = min(ans, abs(num - 753))
print(ans)	

### FIXED CODE ###

s = input()
 
ans = 1000
for i in range(len(s)-2):
    ans = min(ans, abs(753-int(s[i:i+3])))
print(ans)
import sys

def process(data):
	count = 0

	N = int(data[0][0])
	K = int(data[0][1])
	A = list(map(int, data[1])) * K

	for i in range(len(A)-1):
		for j in range(i+1, len(A)):
			if A[i] > A[j]:
				count += 1

	count = count % (10**9+7)
	return count



def main():
	d = []
	for i in range(2):
		data = raw_input()
		data = data.split(" ")
		d.append(data)
	print(process(d))

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys

def process(data):
	count1 = 0
	count2 = 0

	N = int(data[0][0])
	K = int(data[0][1])
	A = list(map(int, data[1]))

	for i in range(len(A)-1):
		for j in range(i+1, len(A)):
			if A[i] > A[j]:
				count1 += 1
	A.reverse()
	
	for i in range(len(A)-1):
		for j in range(i+1, len(A)):
			if A[i] > A[j]:
				count2 += 1	

	count1 = count1 * K*(K+1)/2
	count2 = count2 * (K-1)*K/2

	count = count1 + count2

	count = count % (10**9+7)
	return count



def main():
	d = []
	for i in range(2):
		data = raw_input()
		data = data.split(" ")
		d.append(data)
	print(process(d))

if __name__ == '__main__':
    main()
a=int(raw_input)
b=int(raw_input)

if a>b:
    print "GREATER"
elif a<b:
    print "LESS"
else:
    print "EQUAL"

### FIXED CODE ###

a=int(raw_input())
b=int(raw_input())

if a>b:
    print "GREATER"
elif a<b:
    print "LESS"
else:
    print "EQUAL"
A,B=map(str,input().split())
A=int(A)
B=list(B)
B.remove('.')
n=len(B)
b=sum(10**(n-1-j)*int(B[j]) for j in range(n))
ans=list(str(A*b))
ans.pop(len(ans)-1)
ans.pop(len(ans)-1)
n2=len(ans)
trueans=sum(10**(n2-1-j)*int(ans[j]) for j in range(n2))
print(trueans)

### FIXED CODE ###

A,B=map(str,input().split())
A=int(A)
B=list(B)
if len(B)<=2:
    B.append('0')
    B.append('0')
elif B[-3]=='.':
        B.remove('.')
elif B[-2]=='.' :
    B.remove('.')
    B.append('0')
else:
    B.append('0')
    B.append('0')
n=len(B)
b=sum(10**(n-1-j)*int(B[j]) for j in range(n))
ans=list(str(A*b))
if len(ans)<=2:
    ans='0'
else:
    ans.pop(len(ans)-1)
    ans.pop(len(ans)-1)
n2=len(ans)
trueans=sum(10**(n2-1-j)*int(ans[j]) for j in range(n2))
print(trueans)
S = input()

while S:
    if S[:7] == 'dreamer' and S[7] != 'a':
        S = S[7:]
    elif S[:6] == 'eraser':
        S = S[6:]
    elif S[:5] == 'dream':
        S = S[5:]
    elif S[:5] == 'erase':
        S = S[5:]
    else:
        print('No')
        exit()

print('Yes')

### FIXED CODE ###

S = input()
S = ''.join(list(reversed([c for c in S])))

while S:
    if S[:7] == 'remaerd':
        S = S[7:]
    elif S[:6] == 'resare':
        S = S[6:]
    elif S[:5] == 'maerd':
        S = S[5:]
    elif S[:5] == 'esare':
        S = S[5:]
    else:
        print('NO')
        exit()

print('YES')
N=int(input())
A=list(map(int,input().split()))
m=set(A)
if m%2==0:
  print(m-1)
else:
  print(m)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
m=len(set(A))
if m%2==0:
  print(m-1)
else:
  print(m)
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


N, K = map(int, input().split())
x = combinations_count(N-1, 2)
if K < N-1 and x < K:
    print('-1')
    quit()

for i in range(2,N+1):
    print('1', str(i))

hen = x-K
x = 2
y = 3
while hen > 0:
    print(x,y)
    y += 1
    if y > N:
        x += 1
        y = x+1
    hen -= 1

### FIXED CODE ###

import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


N, K = map(int, input().split())
if N > 2:
    x = combinations_count(N-1, 2)
else:
    x = 0
if x < K:
    print('-1')
    quit()

h = []
for i in range(2,N+1):
    h.append(('1', str(i)))

hen = x-K
x = 2
y = 3
while hen > 0:
    h.append((x,y))
    y += 1
    if y > N:
        x += 1
        y = x+1
    hen -= 1

print(len(h))
for x,y in h:
    print(x,y)
#abc175b
n=int(input())
l=list(map(int,input().split()))
l.sort()
cnt=0
for i in range(n):
 for j in range(i):
  for k in range(j):
   if l[k]!=l[j] and l[i]!=l[j] and l[k]+l[j]>l[i]:
    cnt+=1
print(cnt)


### FIXED CODE ###

#abc17a
s=input()
if 'RRR' in s:
 print(3)
elif 'RR' in s:
 print(2)
elif 'R' in s:
 print(1)
else:
 print(0)
from itertools import combinations

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

min_diff = 10**9
max_diff = 1
min_sum = 2 * 10**9
max_sum = 2

for x,y in XY:
    min_diff = min(x-y, min_x)
    max_diff = max(x-y, max_x)
    min_sum = min(x+y, min_sum)
    max_sum = max(x+y, max_sum)

cand_set = set()
for x,y in XY:
    if x-y in (min_diff, max_diff) or x+y in (min_sum, max_sum):
        cand_set.add((x, y))

dist = 0
for p1, p2 in combinations(cand_set, 2):
    print(p1, p2)
    dist = max(dist, abs(p1[0]-p2[0]) + abs(p1[1]-p2[1]))
    
print(dist)

### FIXED CODE ###

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

min_diff = 10**9
max_diff = -10**9
min_sum = 2 * 10**9
max_sum = 2

for x,y in XY:
    min_diff = min(x-y, min_diff)
    max_diff = max(x-y, max_diff)
    min_sum = min(x+y, min_sum)
    max_sum = max(x+y, max_sum)

print(max(max_sum-min_sum, max_diff-min_diff))
S = int(input())
W = int(input())

if S<W:
    print('unsafe')
elif S>W :
    print('safe')

### FIXED CODE ###

S,W = map(int,input().split())
if S<=W:
    print('unsafe')
elif S>W:
    print('safe')
N,K = map(int,input().split())
A = [int(x) for x in input().split()]

nums = []
nums_2 = []
for i in range(N):
  num = int(A[i])
  s = 0
  k = 0
  for j in range(i+1,N):
    if A[j] < num:
      s += 1
  nums.append(s)
  for t in range(N):
    if A[t] < num:
      k += 1
  nums_2.append(k)

result = 0
for i in range(N):
  result += ((K*(K-1))/2)*(nums_2[i]) + K*nums[i]


print(int(result%(10e+8+7)))

### FIXED CODE ###

month,day = map(int,input().split())

if day < 22:
  print(0)
else:
  s = 0
  for j in range(month+1):
    for i in range(22,day+1):
      num_1 = i%10
      num_2 = (i-num_1)/10
      if  num_1< 2:
        continue
      elif num_1 * num_2 == j:
        s += 1
  print(s)
s = input()
 
n = len(s)
 
ans = 0
 
cunt = 0
 
for i in range(n):
    if s[i] == "B":
        cnt += 1
    else:
        ans += cunt
print(ans)

### FIXED CODE ###

s = input()
 
n = len(s)
 
ans = 0
 
cunt = 0
 
for i in range(n):
    if s[i] == "B":
        cunt += 1
    else:
        ans += cunt
print(ans)
from collections import deque
import numpy as np

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

dist = np.full((H, W), -1, dtype='int8')
dq = deque()

for r in range(H):
    for c in range(W):
        if a[r][c] == '#':
            dist[r, c] = 0
            dq.append((r, c))


def in_range(r, c):
    return 0 <= r < H and 0 <= c < W


dr_s = (0, 0, -1, 1)
dc_s = (-1, 1, 0, 0)

d = 0
while dq:
    r, c = dq.popleft()
    d = dist[r][c]
    for dr, dc in zip(dr_s, dc_s):
        nr = r + dr
        nc = c + dc
        if not in_range(nr, nc): continue
        if dist[nr][nc] != -1: continue
        dist[nr][nc] = d + 1
        dq.append((nr, nc))

print(d)


### FIXED CODE ###

from collections import deque

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

dist = [[-1] * W for _ in range(H)]
dq = deque()

for r in range(H):
    for c in range(W):
        if a[r][c] == '#':
            dist[r][c] = 0
            dq.append((r, c))


def in_range(r, c):
    return 0 <= r < H and 0 <= c < W


dr_s = (0, 0, -1, 1)
dc_s = (-1, 1, 0, 0)

d = 0
while dq:
    r, c = dq.popleft()
    d = dist[r][c]
    for dr, dc in zip(dr_s, dc_s):
        nr = r + dr
        nc = c + dc
        if not in_range(nr, nc): continue
        if dist[nr][nc] != -1: continue
        dist[nr][nc] = d + 1
        dq.append((nr, nc))

print(d)
n, m = (int(xi) for xi in input().split())

a = []
diff = []
a0 = 0
a1 = int(input())
a.append(a1)
diff.append(a1+1)

if m>1:
    for xi in range(m-1):
        a0 = a1
        a1 = int(input())
        a.append(a1)
        diff.append(a1-a0)

if a1==n-1:
    diff.append(n-a1+1)
else:
    diff.append(n-a1+1)

# print(diff)
# print(a)

p = [0]
p.append(1)
p.append(1)
for xi in range(3,n-m):
    p.append(p[xi-1]+p[xi-2])

# print(p)

# print(len(diff))
out = 1
for xi in range(len(diff)):
    out *= p[diff[xi]-1]

print(out% 1_000_000_007 )


### FIXED CODE ###

n, m = (int(xi) for xi in input().split())

a = []
diff = []
a0 = 0
if m>0:
    a1 = int(input())
    a.append(a1)
    diff.append(a1+1)

    if m>1:
        for xi in range(m-1):
            a0 = a1
            a1 = int(input())
            a.append(a1)
            diff.append(a1-a0)

    if a1==n-1:
        diff.append(n-a1+1)
    else:
        diff.append(n-a1+1)


else:
    if n==1: diff.append(n+1)
    diff.append(n+2)

# print(diff)
# print(a)

p = [0]
p.append(1)
p.append(1)
for xi in range(3,max(diff)+2):
    add = (p[xi-1]+p[xi-2])%1_000_000_007
    p.append(add)

# print(p)

# print(len(diff))
out = 1
for xi in range(len(diff)):
    out *= p[diff[xi]-1]

print(out% 1_000_000_007 )
input()

a = map(int, raw_input().split())
a.sort(reverse = True)

edge = []
p = 1
while p < a.size():
  if a[p] == a[p-1]:
    edge.append(a[p])
    p += 2
  else:
    p += 1

edge.append(0)
edge.append(0)
print edge[0] * edge[1]

### FIXED CODE ###

input()

a = map(int, raw_input().split())
a.sort(reverse = True)

edge = []
p = 1
while p < len(a):
      if a[p] == a[p-1]:
              edge.append(a[p])
              p += 2
      else:
              p += 1

edge.append(0)
edge.append(0)
print edge[0] * edge[1]
MOD = 10**9+7
# dp[i][j] := Sの後ろからi桁を13で割った余りがjとなるようなものの個数
S = input()
dp = [[0]*13 for _ in range(len(S)+1)]
dp[0][0] = 1
mul = 1  
for i in range(len(S)):
    x = S[-(i+1)]
    if x == "?":
        for k in range(10):
            for j in range(13):
                dp[i + 1][(mul * k + j) % 13] += dp[i][j]
                dp[i + 1][(mul * k + j) % 13] %= MOD
    else:
        k = int(x) # これしか選ぶ余地なし
        for j in range(13):
            dp[i + 1][(mul * k + j) % 13] += dp[i][j]
            dp[i + 1][(mul * k + j) % 13] %= MOD
    mul = mul * 10 % 13
print(dp[l][5])


### FIXED CODE ###

INF = 10 ** 9 + 7

S = input()
# dp[i][j]はうしろからi桁を13で割った余りがjであるものの個数
dp = [[0] * 13 for _ in range(len(S) + 1)]
dp[0][0] = 1
mul = 1

for i in range(len(S)):
    x = S[-(i + 1)]
    if x == "?":
        for k in range(10):
            for j in range(13):
                dp[i + 1][(mul * k + j) % 13] += dp[i][j]
                dp[i + 1][(mul * k + j) % 13] %= INF
    else:
        k = int(x)
        for j in range(13):
            dp[i + 1][(mul * k + j) % 13] += dp[i][j]
            dp[i + 1][(mul * k + j) % 13] %= INF
    mul = mul * 10 % 13  # 計算量削減のためここで13で割っている

print(dp[len(S)][5])
N = int(input())
A = [int(ai) for ai in input().split()]
ans = 1
if 0 in A:
  print(0)
else:
  for ai in A:
    ans *= ai
    if ans > 10**18:
      print(-1)
      break
  
  print(ans)



### FIXED CODE ###

a, b = map(int,input().split())
p = a * b
print(p)
from collections import Counter

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

check = [0] * (M + 1)

answer = []
for n in range(N):
  tmp = []
  for ai in A:
    for aij in ai:
      if check[aij] == 0:
        tmp.append(aij)
        break
  #print(tmp)
  counter = list(Counter(tmp).items())
  counter.sort(key = lambda x: -x[1])  
  answer.append(counter[0][1])
  check[counter[0][0]] = 1
  
print(min(answer))

### FIXED CODE ###

from collections import Counter

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

check = [0] * (M + 1)

answer = []
for _ in range(M):
  tmp = []
  for ai in A:
    for aij in ai:
      if check[aij] == 0:
        tmp.append(aij)
        break
  #print(tmp)
  counter = list(Counter(tmp).items())
  counter.sort(key = lambda x: -x[1])  
  answer.append(counter[0][1])
  check[counter[0][0]] = 1
  
print(min(answer))
N = int(input())

for i in range(1, N):
    if i*i > N:
        break
        
    res = i * i

print(res)


### FIXED CODE ###

N = int(input())

for i in range(N+1):
    n = i*i
    if n > N:
        break
        
    res = n

print(res)
import math
a,b,c,d = map(int, input().split())
cd = gcd(cd)

def f(x,y,div):
  return int(max(x,y)/div) - int((min(x,y)-1) / div)
print(a-b+1- f(a,b,c) - f(a,b,d) + f(a,b,cd))

### FIXED CODE ###

a, b, c, d = map(int, input().split())
 
def gcd(x, y):
    if x % y == 0:
        return y
    return gcd(y, x%y)
 
cd = c // gcd(c,d) * d

a -= 1
a_ = a - a//c - a//d + a//cd
b_ = b - b//c - b//d + b//cd
 
print(b_ - a_)