CodeEff/ECCO huggingface dataset:
# Original solution
a,b,n=list(map(int,input().split()))
'''
lst=[]
for i in range(n+1):
    now=int(a*i/b)-a*int(i/b)
    lst.append(now)
print(max(lst))
'''
now=0
if n>=b:
    if n//b>=500000:
        ans=int(a*(n-1)/b)-a*int((n-1)/b)
        ans2=int(a*n/b)-a*int(n/b)
        for i in range(0,n//b+1,20000):
            ans3=int(a*(i*b-1)/b)-a*int((i*b-1)/b)
            now=max(now,ans3)
        print((max(ans,ans2,now)))
        exit()
    ans=int(a*(n-1)/b)-a*int((n-1)/b)
    ans2=int(a*n/b)-a*int(n/b)
    for i in range(n//b+1):
        ans3=int(a*(i*b-1)/b)-a*int((i*b-1)/b)
        now=max(now,ans3)
    print((max(ans,ans2,now)))

else:
    ans=int(a*(n)/b)-a*int((n)/b)
    print((max(ans,0)))

# Optimized solution
a,b,n=list(map(int,input().split()))
def ans(x):
    return int(a*x/b)
print((ans(min(n,b-1))))
# Original solution
# -*- coding: utf-8 -*-
a,b,n = list(map(int,input().split()))

ans = 0
tmp = min(b, n)
for x in range(int(pow(n, 0.5)) + 1, n+1):
    #print(x)
    tmp1 = (a * x) // b - (a * (x // b))
    if tmp1 >= ans:
        ans = tmp1
print(ans)


# Optimized solution
# -*- coding: utf-8 -*-
a,b,n = list(map(int,input().split()))
"""
ans = 0
tmp = min(b, n)
for x in range(int(pow(n, 0.5)) + 1, n+1):
    #print(x)
    tmp1 = (a * x) // b - (a * (x // b))
    if tmp1 >= ans:
        ans = tmp1
print(ans)
"""

x = min(b-1, n)
#print(x)
ans = (a * x) // b - (a * (x // b))
print(ans)
# Original solution
import math

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

l = [0]

for x in range(1,n+1):
    ans = 0
    ans = math.floor(a*x/b) - a * math.floor(x/b)
    l.append(ans)
    if l[x] > ans:
        break
#print(l)
print((max(l)))

# Optimized solution
A,B,N=list(map(int,input().split()))
def f(x):
  return int(A*x/B)-A*int(x/B)

print((f(min(N,B-1))))
# Original solution
a, b, n = list(map(int, input().split()))
x = (n//b)*b - 1

if x == -1:
    x = n

ans = a*x//b - a*(x//b)
print(ans)

# Optimized solution
a, b, n = list(map(int, input().split()))

if n <= b - 1:
    x = n
else:
    x = n - (n%b + 1)

ans = a*x//b - a*(x//b)
print(ans)
# Original solution
A,B,N = list(map(int,input().split()))
#N=int(input())
#A = list(map(int,input().split()))
#S=str(input())
m=0
if B<N:
    N=B
s=int(B/A)
if s>N:
    print((0))
    exit()
for x in range(s,N+1):
    num=int(A*x/B) - A * int(x/B)

    m=max(num,m)

print(m)


# Optimized solution
A,B,N = list(map(int,input().split()))
#N=int(input())
#A = list(map(int,input().split()))
#S=str(input())
m=0
if B<=N:
    m=int(A * (B-1) / B)
    print(m)

else:
    m=int(A * N / B)
    print(m)
# Original solution
A,B,N = list(map(int,input().split()))
max_n = -1
endpoint = min(B-1,N)
for i in range(endpoint+1) :
    n = ((A * i) // B) - A * (i // B)
    # print(i,n)
    if (max_n < n) :
        max_n = n

print(max_n)

# Optimized solution
def f(x) :
    return ((A * x) // B) - A * (x // B)

A,B,N = list(map(int,input().split()))
print((f(min(B-1,N))))
# Original solution
import math
a, b, n = list(map(int, input().split()))
def f(n):
    return math.floor(a*n/b) - a*math.floor(n/b)
ans = f(n)
for x in range(b-1, n+1, b):
    ans = max(ans, f(x))
print(ans)

# Optimized solution
from math import floor
a, b, n = list(map(int, input().split()))
def f(x):
    return floor(a*x/b) - a*floor(x/b)
print((f(min(n, b-1))))
# Original solution
from math import floor,ceil
import fractions
import collections
import itertools
from collections import deque
A,B,N=list(map(int,input().split()))

piv=B/A  #基本数

#for i in range(0,30):
#    print(A,i,B,floor(A*i/B)-A*floor(i/B))

#A<=Bなら
#0,0,.. 1,1,.. ... (A-1),(A-1),...が
#先頭から(B%A)の数字まではceil(piv)こ、あとはfloor(piv)こ

cnt=0
#print(ceil(piv)*(B%A))
if A<=B:
    if N>=B-1:
        print((A-1))
    else:
        if ceil(piv)*(B%A)>N:
            print((floor(N/ceil(piv))))
        else:
            N=N-ceil(piv)*(B%A)
            #print(N,N//floor(piv))
            cnt=(B%A)
            print((cnt+N//floor(piv)))
else:  #A>B
    l=[0]
    for i in range(1,B):
        l.append(max(l[i-1],floor(A*i/B)-A*floor(i/B)))
    #print(l)
    if N>=len(l):
        print((l[len(l)-1]))
    else:
        print((l[N]))





# Optimized solution
from math import floor,ceil
import fractions
import collections
import itertools
from collections import deque
A,B,N=list(map(int,input().split()))

piv=B/A  #基本数

#for i in range(0,30):
#    print(A,i,B,floor(A*i/B)-A*floor(i/B))

#A<=Bなら
#0,0,.. 1,1,.. ... (A-1),(A-1),...が
#先頭から(B%A)の数字まではceil(piv)こ、あとはfloor(piv)こ
#→これより、この答えはmod(B)の空間で単調増加とわかる
#よって、f(min(B-1,N))が答え

#A>Bでも同じくmod(B)にて単調増加なのを調べてたはずなので

#いずれにせよf(min(B-1,N))が答え
cnt=0
#print(ceil(piv)*(B%A))
"""
if A<=B:
    if N>=B-1:
        print(A-1)
    else:
        if ceil(piv)*(B%A)>N:
            print(floor(N/ceil(piv)))
        else:
            N=N-ceil(piv)*(B%A)
            #print(N,N//floor(piv))
            cnt=(B%A)
            print(cnt+N//floor(piv))
else:  #A>B
    l=[0]
    for i in range(1,B):
        l.append(max(l[i-1],floor(A*i/B)-A*floor(i/B)))
    #print(l)
    if N>=len(l):
        print(l[len(l)-1])
    else:
        print(l[N])
"""
def f(A,B,N):
    return floor(A*N/B)-A*floor(N/B)
print((f(A,B,min(B-1,N))))
# Original solution
a,b,n=list(map(int,input().split()))
# s=n//b
nmax = (a*n)//b - a*(n//b)
# for i in range(1,s+1):
#     x = b*i-1
#     t = (a*x)//b - a*(x//b)
#     if t > nmax:
#         nmax = t
b_n = b
b_nn = 0
while b_n <= n:
    x = b_n -1
    t = (a*x)//b - a*b_nn
    if t > nmax:
        nmax = t
    b_n += b
    b_nn +=1
print(nmax)

# Optimized solution
a,b,n=list(map(int,input().split()))
s=n//b
nmax = (a*n)//b - a*(n//b)
# b_n = b
# b_nn = 0
# while b_n <= n:
#     x = b_n -1
#     t = (a*x)//b - a*b_nn
#     if t > nmax:
#         nmax = t
#     b_n += b
#     b_nn +=1
if s>0:
    x = b*s-1
    t = (a*x)//b - a*(s-1)
    if t > nmax:
        nmax = t
print(nmax)
# Original solution
import sys
import math
sys.setrecursionlimit(10**9)

def main():
    A,B,N = list(map(int,input().split()))

    def f(x):
        return math.floor((A*x)/B) - A * math.floor(x/B)

    def bin(a):
        left = 0
        right = min(B-1,N)

        while right-left > 1:
            x = (right+left) // 2
            # print(left,right)
            if f(x) < a:
                left = x
            else:
                right = x

        # print("____")
        # print(right)
        return right


    for _a in range(A+1):
        a = A - _a
        x = bin(a)
        # print(x,a)
        if 0<=x<=N and f(x) == a:
            print(a)
            exit()


if __name__ == "__main__":
  main()


# Optimized solution
import sys
import math
sys.setrecursionlimit(10**9)

def main():
    A,B,N = list(map(int,input().split()))

    def f(x):
        return math.floor((A*x)/B) - A * math.floor(x/B)
	
    print((f(min(B-1,N))))


if __name__ == "__main__":
  main()
# Original solution
a,b,n=list(map(int,input().split()))
a1=a*n//b
i=(n+1)//b
if i!=0:
    a2=a*(b-1)//b
    print(a2)
else:
    print(a1)

# Optimized solution
A,B,N=list(map(int,input().split()))
if N>=B:
    print((int(A*(B-1)/B)))
else:
    print((int(A*N/B)))
# Original solution
def resolve():
    n=int(eval(input()))
    l=list(map(int,input().split()))
    from collections import Counter
    c=Counter(l)# ()にカウンターの対象のリストの変数名
    cl=list(c.items())
    cl.sort(key=lambda x:x[0],reverse=True)
    ans=[]
    for key,value in cl:
        if value>=4:
            ans.append(key)
            ans.append(key)
            break
        elif value>=2:
            ans.append(key)
            if len(ans)==2:
                break
    if ans:
        print((ans[0]*ans[1]))
    else:
        print((0))
resolve()

# Optimized solution
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(eval(input()))
    l=list(map(int,input().split()))
    from collections import Counter
    c=Counter(l)# ()にカウンターの対象のリストの変数名
    cl=list(c.items())
    cl.sort(key=lambda x:x[0],reverse=True)
    ans=[]
    for key,value in cl:
        if value>=4:
            if len(ans)==0:
                ans.append(key)
                ans.append(key)
                break
            elif len(ans)==1:
                ans.append(key)
                break
        elif value>=2:
            ans.append(key)
            if len(ans)==2:
                break
    if ans:
        print((ans[0]*ans[1]))
    else:
        print((0))
resolve()
# Original solution
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(eval(input()))
    l=list(map(int,input().split()))
    from collections import Counter
    c=Counter(l)# ()にカウンターの対象のリストの変数名
    cl=list(c.items())
    cl.sort(key=lambda x:x[0],reverse=True)
    ans=[]
    for key,value in cl:
        if value>=4:
            if len(ans)==0:
                ans.append(key)
                ans.append(key)
                break
            elif len(ans)==1:
                ans.append(key)
                break
        elif value>=2:
            ans.append(key)
            if len(ans)==2:
                break
    if ans:
        print((ans[0]*ans[1]))
    else:
        print((0))
resolve()

# Optimized solution
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(eval(input()))
    l=list(map(int,input().split()))
    from collections import Counter
    c=Counter(l)# ()にカウンターの対象のリストの変数名
    ans=[]
    for key,value in list(c.items()):
        if value>=4:
            ans.append(key)
            ans.append(key)
        elif value>=2:
            ans.append(key)
    ans.sort(reverse=True)
    if ans:
        print((ans[0]*ans[1]))
    else:
        print((0))
resolve()
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))
A.sort()
A.reverse()
Ans = []
d = 0
cnt = 0
while cnt < 2:
  c = A.count(A[d])
  for j in range(c//2):
    Ans.append(A[d])
  cnt += c//2
  d += c
  if d == N:
    Ans.append(0)
    Ans.append(0)
    cnt +=2
print((Ans[0]*Ans[1]))

# Optimized solution
N = int(eval(input()))
A = list(map(int, input().split()))
A.sort(reverse=True)
Ans = []
d = 0
cnt = 0
while cnt < 2:
  c = (A[d:d+4]).count(A[d])
  for j in range(c//2):
    Ans.append(A[d])
  cnt += c//2
  d += c
  if d == N:
    Ans.append(0)
    Ans.append(0)
    cnt +=2
print((Ans[0]*Ans[1]))
# Original solution
n=int(eval(input()))
a=list(map(int,input().split()))
f=0
s=0
mx=max(a)

stk=[]
ed=[0,0]
for i in a:
  if i in stk:
    stk.remove(i)
    ed.append(i)
  else:
    stk.append(i)
ans=sorted(ed,reverse=True)
print((ans[0]*ans[1]))


# Optimized solution
n=int(eval(input()))
a=list(map(int,input().split()))
a.sort(reverse=True)
ans=0
b=-1
for i in a:
  if i==b:
    if ans!=0:
      ans*=i
      break
    else:
      ans=i
      b=-1
      continue
  b=i
print(ans)
# Original solution
import collections
s = set()
N = int(eval(input()))
count = []*(10**9+1)
ma1 = 0
ma2 = 0
A = list(map(int,input().split()))
a = collections.Counter(A)
b = sorted(list(a.items()),reverse = True)

for i in b:
  if ma1 == 0 and i[1] > 1:
    ma1 = i[0]
    if i[1] > 3:
      ma2 = i[0]
  elif ma1 != 0 and i[1] > 1:
    ma2 = i[0]
  if ma1 > 0 and ma2 > 0:
    break
  
print((ma1*ma2))
    

# Optimized solution
N = int(eval(input()))
ma1 = 0
ma2 = 0
A = list(map(int,input().split()))
A.append(0)
a = sorted(A,reverse = True)

hold = 0
count = 0

for i in a:
  if i == hold:
    count += 1
  else:
    if count > 3 and ma1 == 0:
      ma1 = hold
      ma2 = hold
    elif count > 1:
      if ma1 == 0:
        ma1 = hold
      elif ma2 == 0:
        ma2 = hold
    hold = i
    count = 1
    if ma1 != 0 and ma2 != 0:
      break
    

print((ma1*ma2))
# Original solution
n = int(eval(input()))
A = list(map(int, input().split()))
d = {}
for i in range(n):
    if A[i] not in d:
        d[A[i]] = 1
    else:
        d[A[i]] += 1
#print(d)

L = []
for k, v in list(d.items()):
    if v >= 2:
        L.append([k, v])
L.sort(reverse=True)
if len(L) == 0:
    print((0))
elif len(L) == 1:
    if L[0][1] < 4:
        print((0))
    else:
        print(((L[0][0])**2))
else:
    if L[0][1] >= 4:
        print(((L[0][0])**2))
    else:
        print((L[0][0]*L[1][0]))


# Optimized solution
n = int(eval(input()))
A =list(map(int, input().split()))
d = {}
for i in range(n):
    if A[i] not in d:
        d[A[i]] = 1
    else:
        d[A[i]] += 1
ans = 0
l = []
for k, v in list(d.items()):
    if v >= 4:
        ans = max(ans, k**2)
        l.append(k)
    elif v >= 2:
        l.append(k)
    else:
        continue
if len(l) <= 1:
    print(ans)
else:
    l.sort(reverse=True)
    ans = max(ans, l[0]*l[1])
    print(ans)
# Original solution
n = int(eval(input()))
A =list(map(int, input().split()))
d = {}
for i in range(n):
    if A[i] not in d:
        d[A[i]] = 1
    else:
        d[A[i]] += 1
ans = 0
l = []
for k, v in list(d.items()):
    if v >= 4:
        ans = max(ans, k**2)
        l.append(k)
    elif v >= 2:
        l.append(k)
    else:
        continue
if len(l) <= 1:
    print(ans)
else:
    l.sort(reverse=True)
    ans = max(ans, l[0]*l[1])
    print(ans)


# Optimized solution
n = int(eval(input()))
A =list(map(int, input().split()))
d = {}
for i in range(n):
    if A[i] not in d:
        d[A[i]] = 1
    else:
        d[A[i]] += 1

s = []
t = []
for k, v in list(d.items()):
    if v >= 4:
        s.append(k)
        t.append(k)
    elif v >= 2:
        t.append(k)

if len(s) == 0 and len(t) < 2:
    print((0))
else:
    if len(s) == 0:
        t.sort(reverse=True)
        print((t[0]*t[1]))
    elif len(t) < 2:
        s.sort(reverse=True)
        print((s[0]**2))
    else:
        t.sort(reverse=True)
        s.sort(reverse=True)
        print((max(t[0]*t[1], s[0]**2)))
# Original solution
from collections import Counter

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

ans = [0, 0]
for k in sorted(list(A.keys()), reverse=True):
    if A[k] >= 2:
        ans.append(k)
    if A[k] >= 4:
        ans.append(k)
ans = sorted(ans)
print((ans[-1]*ans[-2]))


# Optimized solution
from collections import Counter

N = int(eval(input()))
A = Counter(list(map(int, input().split())))
A = {k: v for k, v in list(A.items()) if v >= 2}
A = sorted(list(A.items()), key=lambda x: x[0], reverse=True)
A.extend([(0, 0), (0, 0)])
if A[0][1] >= 4:
    print((A[0][0]**2))
else:
    print((A[0][0]*A[1][0]))
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))
A.sort(reverse=True)

ans = []
s = A[0]
n = 1
for i in range(1, N):
  if len(ans) == 2: break
  if A[i] == s:
    n += 1
    if n == 2 or n == 4:
      ans.append(s)
  else:
    s = A[i]
    n = 1
print((ans[0] * ans[1] if len(ans) != 0 else 0))

# Optimized solution
N = int(eval(input()))
A = list(map(int, input().split()))
A.sort(reverse=True)
a = ""
ans = []
for i in range(N):
  if a == "": a = A[i]
  elif a != A[i]: a = A[i]
  elif A[i] == a:
    ans.append(A[i])
    a = ""
    if len(ans) == 2: break
print((0 if len(ans) != 2 else ans[0] * ans[1]))
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))

#%%
keys = set(A)
keys = sorted(keys, reverse=True)

lengths = []
for k in keys:
    num = A.count(k)
    if num >= 4 and len(lengths) == 0:
        lengths.append(k)
        lengths.append(k)
    elif num >= 2:
        lengths.append(k)

    if len(lengths) == 2:
        break

try:
    ans = lengths[0] * lengths[1]
except:
    ans = 0

print(ans)

# Optimized solution
N = int(eval(input()))
A = sorted(list(map(int, input().split())), reverse=True)

lengths = []
for i in range(len(A) - 1):
    try:
        if A[i] == A[i+3] and len(lengths) == 0:
            lengths.append(A[i])
            lengths.append(A[i])
            break
    except:
        pass

    if (A[i] not in lengths) and (A[i] == A[i+1]):
        lengths.append(A[i])

    if len(lengths) == 2:
        break

try:
    ans = lengths[0] * lengths[1]
except:
    ans = 0

print(ans)
# Original solution
import sys
import heapq
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    N = int(eval(input()))
    A = list(map(int, input().split()))
    A = list(set([-x for x in A if A.count(x) >= 2]))

    if len(A) < 2:
        print((0))
        exit()

    heapq.heapify(A)

    print(((-heapq.heappop(A)) * (-heapq.heappop(A))))


if __name__ == '__main__':
    main()


# Optimized solution
import sys
import heapq
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    N = int(eval(input()))
    s = set()
    q = [0, 0]
    for a in map(int, input().split()):
        if a > q[0]:
            try:
                s.remove(a)
                heapq.heapreplace(q, a)
            except:
                s.add(a)
    print((q[0]*q[1]))


if __name__ == '__main__':
    main()
# Original solution
# ARC081c
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    from collections import Counter

    n = int(eval(input()))
    a = list(map(int, input().split()))
    a.sort(reverse=True)

    mg = 0
    for i in a:
        if a.count(i) > 3 and mg != i:
            if mg == 0:
                print((i**2))
                exit(0)
            print((mg*i))
            exit(0)
        if a.count(i) > 1 and mg != i:
            if mg == 0:
                mg = i
                continue
            print((mg*i))
            exit(0)
    print((0))


if __name__ == '__main__':
    main()


# Optimized solution
# ARC081c
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    from collections import Counter
    import heapq

    n = int(eval(input()))

    def fun(i):
        return -int(i)

    a = list(map(fun, input().split()))
    heapq.heapify(a)

    b = []
    heapq.heapify(b)
    ln = 0
    cou = 0
    mn = 0
    while(len(a) > 0):
        i = -heapq.heappop(a)
        # print(i)
        if ln != i:
            ln = i
            cou = 0
        cou += 1
        if cou > 1:
            heapq.heappush(b, -i)
            cou = 0
    try:
        print((heapq.heappop(b)*heapq.heappop(b)))
    except:
        print((0))


if __name__ == '__main__':
    main()
# Original solution
# ARC081c
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    from collections import Counter
    import heapq

    n = int(eval(input()))

    def fun(i):
        return -int(i)

    a = list(map(fun, input().split()))
    heapq.heapify(a)

    b = []
    heapq.heapify(b)
    ln = 0
    cou = 0
    mn = 0
    while(len(a) > 0):
        i = -heapq.heappop(a)
        # print(i)
        if ln != i:
            ln = i
            cou = 0
        cou += 1
        if cou > 1:
            heapq.heappush(b, -i)
            cou = 0
    try:
        print((heapq.heappop(b)*heapq.heappop(b)))
    except:
        print((0))


if __name__ == '__main__':
    main()


# Optimized solution
# ARC081c
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    from collections import Counter
    import heapq

    n = int(eval(input()))

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

    b = []
    heapq.heapify(b)
    ln = 0
    cou = 0
    for i in a:
        if ln != i:
            ln = i
            cou = 0
        cou += 1
        if cou > 1:
            heapq.heappush(b, -i)
            cou = 0
    try:
        print((heapq.heappop(b)*heapq.heappop(b)))
    except:
        print((0))


if __name__ == '__main__':
    main()
# Original solution
N = int(eval(input()))
a = sorted(list(map(int, input().split())))
val, ans = [], []
for i in a:
    if i in set(val):
        ans.append(i)
    else:
        val.append(i)
ans.sort()
if len(ans) == 0:
    print((0))
else:
    if ans.count(ans[-1]) >= 4:
        print((ans[-1]**2))
    elif ans.count(ans[-1]) == 3:
        print((ans[-1]*ans[-4]))
    elif ans.count(ans[-1]) == 2:
        print((ans[-1]*ans[-3]))
    else:
        print((ans[-1]*ans[-2]))
    


# Optimized solution
N = int(eval(input()))
a = list(map(int, input().split()))
val = set()
ans = []

for i in a:
    if i in val:
        ans.append(i)
    else:
        val.add(i)
ans.sort()
if len(ans) == 0:
    print((0))
else:
    if ans.count(ans[-1]) >= 4:
        print((ans[-1]**2))
    elif ans.count(ans[-1]) == 3:
        print((ans[-1]*ans[-4]))
    elif ans.count(ans[-1]) == 2:
        print((ans[-1]*ans[-3]))
    else:
        print((ans[-1]*ans[-2]))
# Original solution
from collections import Counter
n = int(eval(input()))
a = list(map(int, input().split()))
cnt = Counter(a)
ans = []
for k in sorted(list(cnt.keys()), reverse=True):
    if len(ans) == 2:
        break
    if cnt[k] >= 4:
        ans.append(k)
        ans.append(k)
    elif cnt[k] >= 2:
        ans.append(k)
if len(ans) < 2:
    print((0))
else:
    print((ans[0] * ans[1]))

# Optimized solution
from collections import Counter
n = int(eval(input()))
ctr = Counter(list(map(int, input().split())))
side = []
for k in sorted(list(ctr.keys()), reverse=True):
    if ctr[k] >= 4:
        side.append(k)
        side.append(k)
    elif ctr[k] >= 2:
        side.append(k)
print((side[0] * side[1] if len(side) >= 2 else 0))
# Original solution
import collections
def main():

    n = int(eval(input()))
    a = list(map(int,input().split()))
    cnt = collections.Counter(a)
    set_a = set(a)
    a = []
    a = list(set_a)
    a.sort(reverse=True)
    select = 0
    ans = 1
    tmp = 0
    flg = 0
    for i, aa in enumerate(a):
        if cnt[aa] >= 4 and flg == 0:
            tmp = aa * aa
            flg = 1
        if cnt[aa] >= 2:
            select += 1
            ans *= aa
        if select == 2:
            ans = max(tmp,ans)
            print(ans)
            return
    print((0))



if __name__ == '__main__':
    main()


# Optimized solution
import collections
def main():

    n = int(eval(input()))
    a = list(map(int,input().split()))
    # a.sort(reverse=True)
    c = collections.Counter(a)
    cl = c.most_common()
    # cl.sort(reverse = True)
    cnt = 1
    lst = []
    now = a[0]
    ans = 0
    for i, cc in enumerate(cl):
        if cc[1] >= 4:
            ans = max(ans,cc[0]**2)


        if cc[1] >= 2:
            lst.append(cc[0])
        # if len(lst) == 2:
        #     print(lst[0] * lst[1])
        #     return
    if len(lst) >= 2:
        lst.sort(reverse=True)
        ans = max(ans, lst[0] * lst[1])

    print(ans)
if __name__ == '__main__':
    main()
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))

C = {}

count = 0
H = 0
W = 0

res1=res2=res3=0

for i in A:
    C[i] = 0

for i in A:
    C[i] += 1

for i in A:
    if C[i] >= 2:
        res1 = max(res1, i)

for i in A:
    if C[i] >= 2 and i != res1:
        res2 = max(res2, i)

for i in A:
    if C[i] >= 4:
        res3 = max(res3, i)


print((max(res1 * res2, res3 * res3)))

# Optimized solution
N = int(eval(input()))
A = list(map(int, input().split()))

A.sort()

wh = [0,0]

tmp = 0
for i in A:
    if i == tmp:
        wh.append(i)
        tmp = 0
    else:
        tmp = i

print((wh[-1] * wh[-2]))
# Original solution
N = int(eval(input()))
import collections
A = list(map(int,input().split()))
C = collections.Counter(A)
use = [0,0]
for i,val in list(C.items()):
  if val >= 4:
    use.append(i)
  if val >= 2:
    use.append(i)

use.sort(reverse=True)
 
print((use[0] * use[1]))


# Optimized solution
N = int(eval(input()))
import collections
A = list(map(int,input().split()))
C = collections.Counter(A)
use = []
for i,val in list(C.items()):
  if val >= 4:
    use.append(i)
  if val >= 2:
    use.append(i)

use = sorted(use,reverse= True)
if len(use)<2:
  print((0))
else:
  print((use[0]*use[1]))
# Original solution
from collections import Counter
N = int(eval(input()))
cnt = Counter(list(map(int, input().split())))

L = sum([[a] * (c // 2) for a, c in list(cnt.items())], [])
L.sort()

ans = 0 if len(L) < 2 else L[-1] * L[-2]
print(ans)


# Optimized solution
from collections import Counter
N = int(eval(input()))
cnt = Counter(list(map(int, input().split())))

L = []
for a, c in list(cnt.items()):
    if c >= 2:
        L += [a] * (c // 2)
L.sort()

ans = 0 if len(L) < 2 else L[-1] * L[-2]
print(ans)