CodeEff/ECCO huggingface dataset:
# Original solution
import sys
line = sys.stdin.readline

n = int(line())
a = list(map(int, line().split()))
l = [0 for i in range(max(a)+1)]
for i in a: l[i] += 1
l.reverse()
h = 0
for i in range(len(l)):
    if l[i] > 4:
        print((l[i]))
        sys.exit()
    if l[i] >= 2 and h:
        print(((len(l) - 1 - i) * h))
        sys.exit()
    if l[i] >= 2:
        h = len(l) - 1 - i
print((0))

# Optimized solution
import sys
line = sys.stdin.readline

n = int(line())
a = list(map(int, line().split()))
a.sort(reverse=True)
summ = 0
h = 0
for i in range(len(a)):
    summ += 1
    if i and a[i] != a[i-1]:
        summ = 1
    if summ == 2:
        if h:
            print((a[i] * h))
            sys.exit()
        else:
            h = a[i]
    if summ == 4:
        print((a[i] * a[i]))
        sys.exit()
print((0))
# Original solution
def makerectangle(n , a):

    listmax = []
    a.sort(reverse=True)
    for i in range(n):
        if a.count(a[i]) > 1 and listmax.count(a[i]) == 0:
            if a.count(a[i]) > 3 and len(listmax) == 0:
                return a[i] * a[i]
            else:
                listmax.append(a[i])
        if len(listmax) > 1:
            return listmax[0] * listmax[1]
    return 0



def main():
    n = int(eval(input()))
    a = list(map(int,input().split()))
    print((makerectangle(n , a)))

if __name__ == '__main__':
    main()

# Optimized solution
def makerectangle(n , a):

    listmax = []
    a.sort(reverse=True)
    for i in range(n):
        if len(a) > i + 1 and a[i] == a[i + 1] and listmax.count(a[i]) == 0:
            if len(a) > i + 3 and a[i] == a[i + 3] and len(listmax) == 0:
                return a[i] * a[i]
            else:
                listmax.append(a[i])
        if len(listmax) > 1:
            return listmax[0] * listmax[1]
    return 0


def main():
    n = int(eval(input()))
    a = list(map(int,input().split()))
    print((makerectangle(n , a)))

if __name__ == '__main__':
    main()
# Original solution
import collections
N = int(eval(input()))
A = collections.Counter(list(map(int, input().split())))
seihou = []
tyouhou = []
ans = 0

for i in list(A.keys()):
    if A[i] >= 2:
        tyouhou = tyouhou+[i]
    if A[i] >= 4:
        seihou = seihou+[i]

if len(seihou) >= 1:
    ans = max(seihou)**2

if len(tyouhou) >= 2:
    c = max(tyouhou)
    tyouhou.remove(c)
    ans = max(ans, c*max(tyouhou))
print(ans)

# Optimized solution
import collections
N = int(eval(input()))
A = collections.Counter(list(map(int, input().split())))
seihou = []
tyouhou = []
ans = 0

for i in list(A.keys()):
    if A[i] >= 2:
        tyouhou.append(i)
    if A[i] >= 4:
        seihou.append(i)

if len(seihou) >= 1:
    ans = max(seihou)**2

if len(tyouhou) >= 2:
    c = max(tyouhou)
    tyouhou.remove(c)
    ans = max(ans, c*max(tyouhou))
print(ans)
# Original solution
import collections

N = int(eval(input()))
A = [int(i) for i in input().split()]

con = collections.Counter(A).most_common()
ans = 0

for a, b in sorted(con, reverse= True):
    if b >= 4 and ans == 0:
        print((a**2))
        break
    elif b >= 2 and ans == 0:
        ans = a
    elif b >= 2:
        print((ans*a))
        break
else:
    print((0))

# Optimized solution
import collections

N = int(eval(input()))
A = [int(i) for i in input().split()]

dic = collections.Counter(A).most_common()

tmp = []
check = 0

dic.sort(reverse=True)

for a, b in dic:
    if b >= 2:
        check += 1
        tmp.append(a)
        if b>= 4:
            break
        if check == 2:
            break

if len(tmp) == 0:
    print((0))
elif len(tmp) == 1:
    print((tmp[0]*tmp[0]))
else:
    print((tmp[0] * tmp[1]))
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))
aset = set(a)
aset = sorted(aset, reverse = True)
res = 0
for i in aset:
    count = a.count(i)
    if count >= 4 and res == 0:
        print((i*i))
        exit()
    elif count >= 2 and res == 0:
        res = i
    elif count >= 2:
        print((res * i))
        exit()
print(res)


# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split()))
aset = set(a)
d = {i:0 for i in aset}
for i in range(n):
    d[a[i]] += 1

res = 0
for k, i in sorted(list(d.items()), reverse = True):
    if i >= 4 and res == 0:
        print((k*k))
        exit()
    elif i >= 2 and res == 0:
        res = k
    elif i >= 2:
        print((res * k))
        exit()
print(res)
# Original solution
n = int(eval(input()))
*l, = list(map(int,input().split()))
rect = [i for i in set(l) if l.count(i)>=2]
squ = [i for i in rect if l.count(i)>=4]
rect.sort()
squ.sort()
if len(rect)>=2:
  srect = rect[-1]*rect[-2]
else:
  srect = 0
if len(squ)>=1:
  ssqu=squ[-1]**2
else:
  ssqu=0
print((max([srect,ssqu])))
  

# Optimized solution
n = int(eval(input()))
l = list(map(int,input().split()))
l.sort()
l.reverse()
squ = 0
rec = []
count = 0
tmp = 0
for i in l:
  if i == tmp:
    count += 1
  else:
    tmp = i
    count = 1
  
  if count == 2:
    rec.append(tmp)
  elif count == 4:
    squ = max([squ,tmp])

if len(rec)<2:
  print((squ*squ))
else:
  print((max([squ*squ,rec[0]*rec[1]])))
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))
A = sorted(A, reverse=True)

n4 = []
n2 = set()
for a in A:
    if A.count(a) >= 4:
        if len(n4) >= 1:
            break
        n4.append(a)
    elif A.count(a) >= 2:
        if len(n2) >= 2:
            break
        n2.add(a)
n2 = list(n2)

ans = 0
if len(n2) >= 2:
    ans = n2[0] * n2[1]
for i in n4:
    for j in n2:
        ans = max(ans, i*j)
if len(n4) >= 1:
    ans = max(ans, n4[0] ** 2)

print(ans)

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

for i in range(N):
    if i == 0:
        continue
    elif A[i-1] == A[i]:
        kouho.add(A[i])
        if A.count(A[i]) >= 4 or len(kouho) >= 2:
            break
else:
    ans = 0

kouho = list(kouho)

if len(kouho) >= 2:
    ans = kouho[0] * kouho[1]
elif len(kouho) == 1:
    ans = kouho[0] ** 2

print(ans)
# Original solution
N = int(eval(input()))
A = list(map(int, input().split(' ')))

x = 0
y = 0
S = []

for a in A:
    if a in S:
        if a < x:
            continue
        elif a > y:
            x = y
            y = a
        else:
            x = a
        S.remove(a)
    else:
        S.append(a)

print((x*y))


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

x = 0
y = 0
S = set()

for a in A:
    if a in S:
        if a < x:
            continue
        elif a > y:
            x = y
            y = a
        else:
            x = a
        S.remove(a)
    else:
        S.add(a)

print((x*y))
# Original solution
n = int(eval(input()))
a = [int(_) for _ in input().split()]

a_sorted = sorted(a, reverse=True)
x = 0
y = 0

while True:
    if len(a_sorted) == 0:
        break
    max = a_sorted[0]
    if x != 0 and y != 0:
        break
    if a_sorted.count(max) >= 2:
        if x == 0:
            x = max
        else:
            y = max
        a_sorted.remove(max)
        a_sorted.remove(max)
    else:
        a_sorted.remove(max)
print((x * y))

# Optimized solution
n = int(eval(input()))
a = [int(_) for _ in input().split()]

a_sorted = sorted(a, reverse=True)
x = 0
y = 0

while True:
    if len(a_sorted) <= 1:
        break
    max = a_sorted[0]
    if x != 0 and y != 0:
        break
    if a_sorted[1] == max:
        if x == 0:
            x = max
        else:
            y = max
        a_sorted.remove(max)
        a_sorted.remove(max)
    else:
        a_sorted.remove(max)
print((x * y))
# Original solution
def inpl():
    return input().split()

n = int(eval(input()))
a = list(map(int, inpl()))
a = sorted(a, reverse=True)

ans = 1
cnt = 0
bf = a[0]
i = 1
while (i < n) and (cnt < 2):
    a_i = a[i]
    if bf == a_i:
        ans *= a_i
        bf = -1
        cnt += 1
    else:
        bf = a_i
    i += 1
print((ans if cnt == 2 else 0))

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

anss = []
t = -1
for i in range(n):
    if t == a[i]:
        anss.append(t)
        t = -1
        if len(anss) >= 2:
            break
    else:
        t = a[i]

if len(anss) >= 2:
    ans = 1
    for x in anss:
        ans *= x
else:
    ans = 0
print(ans)
# Original solution
import sys

N = int(eval(input()))
A = list(map(int, input().split()))
A = sorted([e for e in A if A.count(e) > 1], reverse = True)

c = None
for a in A:
    if A.count(a) >= 2:
        if c is not None:
            print((c * a))
            sys.exit()
    c = a
    A.remove(a)
    A.remove(a)
print((0))


# Optimized solution
import sys

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

mstack = []
stack = [0]
for a in A:
    if a == stack[-1]:
        mstack.append(a)
        stack.pop()
        if len(mstack) >= 2:
            print((mstack[-1] * mstack[-2]))
            sys.exit()
    else:
        stack.append(a)
print((0))
# Original solution
n=int(eval(input()))
l=[int(i) for i in input().split()]
from collections import Counter 
c=Counter(l) 
ans=[]
for i in c: 
    if c[i]>=2:
        ans=ans+[i]*(c[i]//2)
ans.sort(reverse=1)
if len(ans)<=1:
    print((0))
else: 
    print((ans[0]*ans[1]))

# Optimized solution
n=int(input())
l=[int(i) for i in input().split()]
from collections import Counter 
c=Counter(l) 
ans=[]
for i in c: 
    if c[i]>=2:
        ans=ans+[i]*(c[i]//2)
ans.sort(reverse=1)
if len(ans)<=1:
    print((0))
else: 
    print((ans[0]*ans[1]))
# Original solution
n=int(eval(input()))
a=list(map(int,input().split()))
b=[]
max1=0;max2=0
for i in range(n-1):
  for j in range(i+1,n):
    if a[i]==a[j]:
      if a[i]>max1:
        max2=max1
        max1=a[i]
      elif a[i]>max2:
        max2=a[i]
      a[j]=0
      break
print((max1*max2))


# Optimized solution
n=int(eval(input()))
a=list(map(int,input().split()))
a.sort()
a.reverse()
max1=0;max2=0
count=0
for i in range(n-3):
  if a[i]==a[i+1]:
    max1=a[i]
    a[i+1]=0
    count=i+1
    break
if count==0:
  print((0))
  exit()
for j in range(count,n-1):
  if a[j]==a[j+1]:
    max2=a[j]
    break
print((max1*max2))
# Original solution
import sys
stdin = sys.stdin

def li(): return list(map(int, stdin.readline().split()))
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return list(map(float, stdin.readline().split()))
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from collections import Counter

n = ni()
a = list(li())

cnt = Counter(a)

lst = []
for k,v in list(cnt.items()):
    lst.append((k,v))

lst.sort(reverse=True)

first = 0
second = 0

for k,v in lst:
    if v >= 4 and first == 0:
        first = k
        second = k
        break
    
    elif v >= 4:
        second = k
        break
        
    elif v >= 2 and first != 0:
        second = k
        break
    
    elif v >= 2:
        first = k
        
print((first*second))

# Optimized solution
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return list(map(int, stdin.readline().split()))
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return list(map(float, stdin.readline().split()))
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from collections import Counter

n = ni()
a = list(li())

cnt = Counter(a)

first = 0
second = 0

keys = list(cnt.keys())
keys.sort(reverse=True)

for k in keys:
    if first != 0 and second != 0:
        break
    
    if first == 0 and second == 0 and cnt[k] >= 4:
        first = k
        second = k
        
    elif first != 0 and cnt[k] >= 2:
        second = k
        
    elif cnt[k] >= 2:
        first = k
        
print((first * second))
# Original solution
N = int(eval(input()))

arr = list(map(int,input().split()))
arr = sorted(arr,reverse=True)

to_multiply = []
while len(to_multiply) < 2 and len(arr) > 1:
    if arr[0] == arr[1]:
        to_multiply.append(arr[0])
    arr = arr[2:]
if len(to_multiply) == 2:
    print((to_multiply[0] * to_multiply[1]))
else:
    print("0")


# Optimized solution
N = int(eval(input()))
freq = {}
arr = list(map(int,input().split()))
for i in arr:
    try:
        freq[i] += 1
    except KeyError:
        freq[i] = 1

to_multiply = []      
for i in sorted(list(freq.keys()),reverse=True):
    if freq[i] >= 4:
        to_multiply.append(i)
        to_multiply.append(i)
    elif freq[i] >= 2:
        to_multiply.append(i)
if len(to_multiply) >= 2:
    print((to_multiply[0] * to_multiply[1]))
else:
    print("0")
# Original solution
from collections import Counter

n = eval(input())
bou = list(map(int,input().split()))

bous = Counter(bou)
hen = []
ans = -1

i = 0
while(i<2):
    if len(bous) == 0:
        ans = 0
        break
    
    mkey = max(bous.keys())
    if bous[mkey] > 3:
        bous[mkey] = bous[mkey] - 2
        hen.append(mkey)
        i += 1
    elif bous[mkey] > 1:
        hen.append(mkey)
        bous.pop(mkey)
        i += 1
    else:
        bous.pop(mkey)
    
if ans:
    print((hen[0]*hen[1]))
else:
    print(ans)

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

a.sort(reverse=True)

num = None
hen = []
en = 0

for i in a:
    if en == 2:break
    if num == i:
        hen.append(num)
        num = None
        en += 1
    else:
        num = i
        
if en == 2:
    print((hen[0]*hen[1]))
else:
    print((0))
# Original solution
n=int(eval(input()))
a=sorted(list(map(int,input().split())),reverse=True)
x,y=0,0
def groupby(a):
    a2=[[a[0],1]]
    for i in range(1,len(a)):
        if a2[-1][0]==a[i]:
            a2[-1][1]+=1
        else:
            a2.append([a[i],1])
    return a2
b=groupby(a)
l=len(b)
for i in range(l):
    if x==0:
        if b[i][1]>=4:
            x,y=b[i][0],b[i][0]
        elif b[i][1]>=2:
            x=b[i][0]
    elif y==0:
        if b[i][1]>=2:
            y=b[i][0]
    else:
        break
print((x*y))

# Optimized solution
n =int(eval(input()))
a = list(map(int,input().split()))
a.sort()
x,y,i = 0,0,0
while i<n:
  if a[i-1] == a[i]:
    x,y = y,a[i]
    i += 1
  i += 1
print((x*y))
# Original solution
from collections import*
n,*a=list(map(int,open(0).read().split()))
r=[];s=[]
for k,v in list(Counter(a).items()):
	if v>1:
		r+=[k]
	if v>3:
		s+=[k]
if len(r)<2 and len(s)<1:
	print((0))
	exit()
r+=[0,0]
s+=[0]
r.sort()
s.sort()
print((max(r[-1]*r[-2],s[-1]**2)))

# Optimized solution
from collections import*
n,*a=list(map(int,open(0).read().split()))
r=[0,0];s=[0]
for k,v in list(Counter(a).items()):
	if v>1:
		r+=[k]
	if v>3:
		s+=[k]
r.sort();s.sort()
print((max(r[-1]*r[-2],s[-1]**2)))
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))

import collections
ans = 0
c = collections.Counter(A)
lis = []
for k,v in list(c.items()):
  if v>=2:
    lis.append(k)
  if v>=4:
    lis.append(k)
if len(lis)>=2:
  lis.sort()
  ans = lis[-1]*lis[-2]
print(ans)

#print(*ans, sep='\n')


# Optimized solution
from collections import Counter
def solve():
    ans = 0
    N = int(eval(input()))
    A = list(map(int, input().split()))
    C = Counter(A)
    D = [[0,0],[0,0]]
    for k,v in list(C.items()):
        if v>=2:
            D.append([k,v])
    D.sort(reverse=True)
    if D[0][1]>=4:
        return D[0][0]**2
    return D[0][0]*D[1][0]
print((solve()))
# Original solution
n=int(eval(input()))
a=list(map(int,input().split()))
b=[]
for i in a:
    if a.count(i)>=2:
        b.append(i)
b=sorted(b,reverse=True)
if len(b)<=1:
    print((0))
elif b.count(b[0])>=4:
    print((b[0]*2))
else:
    b=list(set(b))
    b=sorted(b,reverse=True)
    print((b[0]*b[1]))

# Optimized solution
n=int(eval(input()))
a=sorted(list(map(int,input().split())),reverse=True)
h,w,i=0,0,0
while i<n-1:
    if a[i]==a[i+1]:
        if h==0:
            h=a[i]
            i+=1 #
        else:
            w=a[i]
            break
    i+=1
print((h*w))
# Original solution
import collections
n = int(eval(input()))
a = [int(i) for i in input().split()]
a.sort()
a = a[::-1]
x,answer,num = collections.Counter(a),1,-1
while a != []:
	if x[a[0]]>=4 and num==-1:
		print((a[0]**2))
		break
	elif x[a[0]]>=2:
		answer *= a[0]
		num += 1
		if num==1:
			print(answer)
			break
	a = a[x[a[0]]:]
	if a == []:
		print((0))

# Optimized solution
import collections
n = int(eval(input()))
a = [int(i) for i in input().split()]
x,y,z = collections.Counter(a),[0],[0,0]
for i in list(x.keys()):
	if x[i]>=4:
		y.append(i)
	if x[i]>=2:
		z.append(i)
y,z = sorted(y),sorted(z)
print((max(y[-1]**2,z[-1]*z[-2])))
# Original solution

r = int(eval(input()))

stick = [int(v) for v in input().split()]
stick = sorted(stick, reverse=True)
s_stick = sorted(set(stick), reverse=True)

line = []
for v in s_stick:
    if stick.count(v) >= 4:
        if len(line) == 0:
            print((v * v))
            exit()
        else:
            print((line[0] * v))
            exit()
    if stick.count(v) >= 2:
        line.append(v)
        if len(line) == 2:
            print((line[0] * line[1]))
            exit()
print((0))

# Optimized solution
def main2():
    r = int(eval(input()))

    stick = [int(v) for v in input().split()]
    stick = sorted(stick, reverse=True)

    line = []
    tmp = -1
    for i in range(0, len(stick), 1):
        if tmp == stick[i]:
            line.append(stick[i])
            tmp = -1
        else:
            tmp = stick[i]
        if len(line) == 2:
            print((line[0] * line[1]))
            exit()
    print((0))

main2()
# Original solution
N = int(eval(input()))

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

A.sort()

s1 = 0
s2 = 0

t = -1
for a in A:
    if a != t:
        ac = A.count(a)
        if ac >= 4:
            s1 = a
            s2 = a
        elif ac >= 2:
            s2 = s1
            s1 = a

    t = a

print((s1 * s2))


# Optimized solution
N = int(eval(input()))

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

A.sort()

s1 = 0
s2 = 0

at = -1
atc = 0

for a in A:
    if at == a:
        atc += 1

    else:
        if atc >= 4:
            s1 = at
            s2 = at
        elif atc >= 2:
            s2 = s1
            s1 = at
        
        at = a
        atc = 1

if atc >= 4:
    s1 = at
    s2 = at
elif atc >= 2:
    s2 = s1
    s1 = at

print((s1 * s2))
# Original solution
N = int(eval(input()))
A = list(map(int,input().split()))
B = sorted([a for a in set(A) if 2<=A.count(a)])[::-1]
x = 0
y = 0

for b in B:
  if x==0:
    if 4<=A.count(b):
      x = b
      y = b
    elif 2<=A.count(b):
      x = b
  else:
    if 2<=A.count(b):
      y = b

  if x*y!=0:
    break

print((x*y))

# Optimized solution
N = int(eval(input()))
A = sorted(list(map(int,input().split())))[::-1]

for n in range(N-1):
  if A[n]==A[n+1]:
    A[n+1]=0
  else:
    A[n]=0

A = sorted(A)[::-1]
print((A[0]*A[1]))
# Original solution

eval(input())
xs = list(map(int, input().split()))

d = dict()
for x in xs:
    if x in list(d.keys()):
        d[x] += 1
    else:
        d[x] = 1

res = 0
for x, c1 in list(d.items()):
    if c1 >= 4:
        if res < x * x: res = x * x
    for y, c2 in list(d.items()):
        if x != y and c1 >= 2 and c2 >= 2:
            if res < x * y: res = x * y


print(res)


# Optimized solution

eval(input())
xs = list(map(int, input().split()))

d = dict()
for x in xs:
    if x in list(d.keys()):
        d[x] += 1
    else:
        d[x] = 1

res = 0
for x, c1 in list(d.items()):
    if c1 >= 4:
        if res < x * x: res = x * x

v = sorted(list([s[0] for s in ([x for x in list(d.items()) if x[1] >= 2])]), reverse=True)

if len(v) >= 2:
    if res < v[0] * v[1]: res = v[0] * v[1]

"""
    for y, c2 in d.items():
        if x != y and c1 >= 2 and c2 >= 2:
            if res < x * y: res = x * y
"""


print(res)
# Original solution
from collections import deque
n = int(eval(input()))
a = list(map(int, input().split()))
b = sorted(set(a), reverse=True)
c = deque([])
for i in b:
    if a.count(i) >= 4 and c == deque([]):
        print((i*i))
        exit(0)
    elif a.count(i) >= 2:
        c.append(i)
        if len(c)==2:
            print((c[0]*c[1]))
            exit(0)
print((0))


# Optimized solution
from collections import Counter, deque
n = int(eval(input()))
a = list(map(int, input().split()))
b = Counter(a)
c = deque([])
for k in list(b.keys()):
    if b[k]>=4:
        c.append(k)
        c.append(k)
    elif b[k]>=2:
        c.append(k)
c = sorted(c, reverse = True)
print((c[0]*c[1] if c else 0))
# Original solution
N = int(eval(input()))
A = list(map(int,input().split()))
import collections
a = collections.Counter(A)
b = []
for i in range(len(a)):
    if a.most_common()[i][1] >= 2:
        b.append(a.most_common()[i])
    else:
        break
b.sort()
if len(b) >= 1 and b[-1][1] >= 4:
    print((b[-1][0] ** 2))
elif len(b) >= 2:
    print((b[-1][0] * b[-2][0]))
else:
    print((0))

# Optimized solution
N = int(eval(input()))
A = list(map(int,input().split()))
import collections
a = collections.Counter(A)
b = []
for i, j in list(a.items()):
    if j >= 2:
        b.append([i,j])
b.sort(reverse=True)
if len(b) >= 1 and b[0][1] >= 4:
    print((b[0][0] ** 2))
elif len(b) >= 2:
    print((b[0][0] * b[1][0]))
else:
    print((0))
# Original solution
from collections import defaultdict
n = int(eval(input()))
a_list = [int(x) for x in input().split()]
d = defaultdict(int)
for a in a_list:
    d[a] += 1
temp_list = sorted([(k, v) for k, v in list(d.items()) if v >= 2], reverse=True)
if len(temp_list) >= 2:
    print((temp_list[0][0] ** 2 if temp_list[0][1] >= 4 else temp_list[0][0] * temp_list[1][0]))
else:
    print((0))

# Optimized solution
n = int(eval(input()))
a_list = sorted([int(x) for x in input().split()], reverse=True)
ans = 0
temp = 0
count = 0
e = None
for i in range(n):
    if a_list[i] == temp:
        count += 1
        if count == 2:
            if e is None:
                e = temp
                count -= 2
            else:
                ans = e * temp
                break
    else:
        temp = a_list[i]
        count = 1
print(ans)
# Original solution
n=eval(input())
temp=[]
l=[int(x) for x in input().split()]
for x in l:
	if x not in temp:
		y=l.count(x)
		if y>3:
			temp.append(x)
		if(y>1):
			temp.append(x)
	
if len(temp)<2:
	print((0))
else:
	x=max(temp)
	temp.remove(x)
	print((x*max(temp)))


# Optimized solution
n=int(eval(input()))
a=[int(x) for x in input().split()]
a.sort()
lar=sec=i=0
while(i<n-1):
    if a[i]==a[i+1]:
        i+=1
        if a[i]>lar:
            sec=lar
            lar=a[i]
        elif a[i]>sec:
             sec=a[i]
    i+=1
print((lar*sec))
# Original solution
n = int(eval(input()))

sList = list(map(int,input().split()))
sEdit = sorted(list(set(sList)),reverse=True)
res = 0
for i in sEdit:
  dcount = sList.count(i)//2
  if dcount >= 2 and res == 0:
    print((i*i))
    exit(0)
  elif dcount >= 1 and res == 0:
    res = i
  elif dcount >= 1 and res != 0:
    print((res*i))
    exit(0)

print((0))



# Optimized solution
n = int(eval(input()))

sList = sorted(list(map(int,input().split())),reverse=True)
res = []
acc = False
for i in range(n-1):
  if acc:
    acc = False
  else:
      if sList[i] == sList[i+1]:
        res.append(sList[i])
        acc = True
      if len(res) == 2:
        print((res[0]*res[1]))
        exit(0)

print((0))
# Original solution
n = int(eval(input()))
a = list(input().split())
num_list = []

for i in range(len(a)-1):
    for j in range(i+1, len(a)):
        if a[i] == a[j] and int(a[i]) not in num_list:
            num_list.append(int(a[i]))
            break

if len(num_list) < 2:
    print("0")
else:
    num_list.sort()
    print((num_list[-1]*num_list[-2]))


# Optimized solution
n = int(eval(input()))
a_in = list(input().split())
a = list(map(int,a_in))
a.sort(reverse=True)
ans = 0
t = 0
c = 1

for i in range(n-1):
    if a[i] == a[i+1]:
        c = c + 1
        if t == 0:
            t = int(a[i])
        elif t != int(a[i]):
            ans = t * int(a[i])
            break
        elif c == 4:
            ans = t * t
            break
    else:
        c = 1

print(ans)