CodeEff/ECCO huggingface dataset:
# Original solution
from collections import Counter
N = int(eval(input()))
cnt = Counter(list(map(int, input().split())))

L = sum([[a for _ in range(min(2, 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()))
A = Counter(list(map(int, input().split())))

S = []
for a, c in list(A.items()):
    S.extend([a] * (c // 2))

S.sort()
if len(S) < 2:
    print((0))
else:
    print((S[-1] * S[-2]))
# Original solution
import sys

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

# rstrip().decode('utf-8')
# map(int,input().split())
# import numpy as np

from collections import defaultdict

def main():
	d=defaultdict(int)
	
	n=int(eval(input()))
	A=list(map(int,input().split()))
	for x in A:
		d[x]+=1
	
	li=[]
	li2=[]
	for k,v in list(d.items()):
		if v>=2:
			li.append(k)
		if v>=4:
			li2.append(k)

	li.sort(reverse=True)
	li2.sort(reverse=True)
	
	if len(li)<=1 and len(li2)==0:
		print((0))
	elif len(li)>=2 and len(li2)>=1:
		print((max(li[0]*li[1],li2[0]**2)))
	elif len(li)>=2:
		print((li[0] * li[1]))
	else:
		print((li2[0]**2))
	

if __name__ == "__main__":
	main()


# Optimized solution
import sys

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

# rstrip().decode('utf-8')
# map(int,input().split())
# import numpy as np


def main():
	n=int(eval(input()))
	A=list(map(int,input().split()))
	A.sort(reverse=True)
	ans=0
	cnt=0
	li=[]
	for i in range(n-1):
		if A[i+1]==A[i]:
			cnt+=1
			if cnt==3:
				ans=A[i]**2
				break
			if cnt==1:
				li.append(A[i])
				if len(li)==2:
					ans=li[0]*li[1]
					break
		else:
			cnt=0
	print(ans)
	
	

if __name__ == "__main__":
	main()
# Original solution
from collections import Counter

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

c = Counter(A)

hen = []

for i,j in zip(list(c.keys()),list(c.values())):
    if 2 <= j <= 3:
        hen.append([i,2])
    elif j >= 4:
        hen.append([i,4])


hen.sort(reverse=True)

##print(hen)
ans = 0
finished = False
choosen = False

for i,j in hen:
    if choosen:
        ans *= i
        finished = True
        break

    if j == 2:
        ans = i
        choosen = True
    else:
        ans = i**2
        finished = True
        break

print((ans if finished else 0))

# Optimized solution
from collections import Counter

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

c = Counter(A)

hen = []

for i,j in zip(list(c.keys()),list(c.values())):
    if 2 <= j <= 3:
        hen.append([i,2])
    elif j >= 4:
        hen.append([i,4])


hen.sort(reverse=True)

##print(hen)
ans = 0
finished = False
choosen = False

for i,j in hen:
    if j == 2:
        if choosen:
            ans *= i
            finished = True
            break
        else:
            ans = i
            choosen = True
    else:
        if choosen:
            ans *= i
            finished = True
            break
        else:
            ans = i**2
            finished = True
            break

print((ans if finished else 0))
# Original solution
def solve():
    N = int(eval(input()))
    A = [int(a) for a in input().split()]
    A.sort()

    Adict = dict()
    for i, a in enumerate(A):
        if a in Adict: Adict[a] += 1
        else: Adict[a] = 1

    rect = 0
    ri = -1
    for i in reversed(list(range(N))):
        if Adict[A[i]] >= 4:
            rect = A[i] ** 2
            break
        if Adict[A[i]] >= 2:
            rect = A[i]
            ri = i
            break
    if ri > -1:
        for i in reversed(list(range(ri))):
            if Adict[A[i]] >= 2 and A[i] != rect:
                rect *= A[i]
                break
    print(rect)

if __name__ == "__main__":
    solve()


# Optimized solution
import sys
from heapq import heapify, heappop, heappush

def solve():
    input = sys.stdin.readline
    N = int(eval(input()))
    A = [int(a) for a in input().split()]
    Anum = dict()
    for a in A:
        if a in Anum: Anum[a] += 1
        else: Anum[a] = 1
    q = [0, 0]
    for key in Anum:
        if Anum[key] >= 2: q.append(-key)  
        if Anum[key] >= 4: q.append(-key)
    heapify(q)
    x = heappop(q)
    y = heappop(q)
    print((x * y))


    return 0

if __name__ == "__main__":
    solve()
# Original solution
from collections import defaultdict

eval(input())
t = defaultdict(lambda: 0)
for e in [int(i) for i in input().split()]:
  t[e] += 1
ans = []
for k, v in list(t.items()):
  if v >= 2:
    if v >= 4:
      ans.extend([k, k])
    else:
      ans.append(k)
ans.sort()
if len(ans) < 2:
  print((0))
else:
  print((ans[-1]*ans[-2]))


# Optimized solution
from collections import Counter

eval(input())
t = Counter([int(i) for i in input().split()])
ans = []
for k, v in list(t.items()):
  if v >= 2:
    if v >= 4:
      ans.extend([k, k])
    else:
      ans.append(k)
ans.sort()
if len(ans) < 2:
  print((0))
else:
  print((ans[-1]*ans[-2]))
# Original solution
from collections import Counter
N = int(eval(input()))
a = list(map(int,input().split()))
c = Counter(a)
ans = 0
s = []
for e in c:
    if c[e] >= 2:
        s.append(e)
    if c[e] >= 4:
        ans = max(ans,e*e)
s = sorted(s)
if len(s) < 2:
    print((0))
else:
    print((max(ans,s[-1]*s[-2])))


# Optimized solution
from collections import Counter
N = int(eval(input()))
A = list(map(int,input().split()))
C = Counter(A)
T = []
F = []
for e in C:
    if C[e] >= 4:
        F.append(e)
    if C[e] >= 2:
        T.append(e)
ans = 0
for e in F:
    ans = max(ans,e**2)
T = sorted(T)
if len(T) >= 2:
    ans = max(ans,T[-1]*T[-2])
print(ans)
# Original solution
N=int(eval(input()))
A=list(map(int,input().split()))
B=[]
C=[]
for i in range(N):
  if A[i] in B:
    C+=[A[i]]
    B.remove(A[i])
  else: 
    B+=[A[i]]
C.sort(reverse=1)
if len(C)<2:
  print((0))
else:
  print((C[0]*C[1]))

# Optimized solution
import sys
N=int(eval(input()))
A=list(map(int,input().split()))
A.sort(reverse=1)
a=0
b=0
j=N-1
for i in range(N-1):
  if A[i]==A[i+1]:
    a=A[i]
    j=i
    break
for i in range(j+2,N-1):
  if A[i]==A[i+1]:
    b=A[i]
    break

print((a*b))
# Original solution
import collections
N = int(eval(input()))
A = list(map(int, input().split()))
a = collections.Counter(A)
ans = [0, 0]
for i in list(a.keys()):
    if a[i] >= 2:
        ans.append(i)
    if a[i] >= 4:
        ans.append(i)
ans.sort()
print((ans[-1]*ans[-2]))

# Optimized solution
from collections import Counter

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

c = Counter(A)


ans = [0, 0]
for i, j in list(c.items()):
    if j >= 2:
        ans.append(i)
    if j >= 4:
        ans.append(i)

ans.sort()    

print((ans[-1]*ans[-2]))
# Original solution
def main():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = list(map(int, input().rstrip('\n').split()))
    import collections
    a = collections.Counter(a).most_common()
    a = sorted(a, key=lambda x: x[0], reverse=True)
    t = -1
    for k, v in a:
        if v >= 4:
            if t != -1:
                print((t * k))
                exit()
            else:
                print((k ** 2))
                exit()
        elif v >= 2:
            if t != -1:
                print((t * k))
                exit()
            else:
                t = k
    print((0))

if __name__ == '__main__':
    main()


# Optimized solution
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = list(map(int, input().rstrip('\n').split()))
    a = sorted(collections.Counter(a).most_common(), key=lambda x: x[0], reverse=True)
    ans = []
    for k, v in a:
        if v >= 2:
            for i in range(v // 2 * 2):
                ans.append(k)
        if len(ans) >= 4:
            print((ans[0] * ans[2]))
            exit()
    print((0))


if __name__ == '__main__':
    slove()
# Original solution
from collections import defaultdict

n = int(eval(input()))
A = list(map(int, input().split()))
d = defaultdict(int)
l = []
for key in A:
  d[key] += 1
  if d[key] == 2:
    l.append(key)
    d[key] = 0
if len(l) < 2:
  print((0))
else:
  l.sort(reverse=True)
  print((l[0]*l[1]))

# Optimized solution
from collections import Counter

n = int(eval(input()))
A = list(map(int, input().split()))
C = Counter(A)
L = []
for k, v in list(C.items()):
  if v >= 2:
    L.append(k)
  if v >= 4:
    L.append(k)
if len(L) < 2:
  print((0))
else:
  L.sort()
  ans = L[-1] * L[-2]
  print(ans)
# Original solution
N = int(eval(input()))
A = list(map(int,input().split()))
from collections import Counter
ctr = Counter(A)

e = -1
for k,v in sorted(list(ctr.items()), reverse=True):
    if v < 2: continue
    if e > 0:
        print((e*k))
        exit()
    elif v >= 4:
        print((k*k))
        exit()
    else:
        e = k
print((0))

# Optimized solution
N = int(eval(input()))
A = list(map(int,input().split()))
from collections import Counter
ctr = Counter(A)
x = None
for k,v in reversed(sorted(ctr.items())):
    if v >= 4:
        if x:
            print((x*k))
        else:
            print((k**2))
        exit()
    if v >= 2:
        if x:
            print((x*k))
            exit()
        x = k
print((0))
# Original solution
from collections import Counter
N = int(eval(input()))
Ac = Counter(list(map(int, input().split())))
sticks = sorted({k:v for k, v in list(Ac.items()) if v >= 2}.items())[::-1]
if len(sticks) == 0:
    print((0))
else:
    if sticks[0][1] >= 4:
        print((sticks[0][0]**2))
    else:
        print((sticks[0][0]*sticks[1][0]))


# Optimized solution
from collections import Counter
N = int(eval(input()))
Alist = list(map(int, input().split()))
Ac = Counter(Alist)
length_list = sorted(list(Ac.keys()), reverse=True)
can_use = []
for l in length_list:
    if Ac[l] >= 4:
        if can_use:
            print((can_use[0]*l))
            exit()
        else:
            print((l**2))
            exit()
    elif Ac[l] >= 2:
        if can_use:
            print((can_use[0]*l))
            exit()
        else:
            can_use.append(l)

print((0))
# Original solution
# -*- coding: utf-8 -*-
from collections import Counter
N = int(eval(input()))
A = tuple(map(int, input().split()))
c = Counter(A)

pairs = []
for k, v in list(c.items()):
    if v >= 4:
        pairs.extend([k]*2)
    elif v >= 2:
        pairs.append(k)

if len(pairs) >= 2:
    a, b = sorted(pairs, reverse=True)[:2]
    print((a*b))
else:
    print((0))

# Optimized solution
# -*- coding: utf-8 -*-
from collections import Counter
def inpl(): return list(map(int, input().split()))

N = int(eval(input()))
C= Counter(inpl())

F = sorted([k for k, v in list(C.items()) if v >= 4] + [0])
T = sorted([k for k, v in list(C.items()) if v >= 2] + [0, 0])

print((max(F[-1]*F[-1], T[-1]*T[-2])))
# Original solution
from sys import stdin, stdout
def readLine_int_list():return list(map(int, stdin.readline().split()))


def main():
    n = int(eval(input()))
    a = readLine_int_list()
    set_a = sorted(list(set(a)), reverse=True)
    
        
    
    pair = []
    
    ans = 0
    if len(a) - len(set_a) == 1:
        print(ans)
    else:
        for i in set_a:
            c = a.count(i)
            if c > 3:
                pair.append(i)
                pair.append(i)
            elif c > 1:
                pair.append(i)
                
            if len(pair) >= 2:
                ans = pair[0] * pair[1]
                break
    
        print(ans)


if __name__ == '__main__':
    main()


# Optimized solution
from sys import stdin, stdout
def readLine_int_list():return list(map(int, stdin.readline().split()))


def main():
    n = int(eval(input()))
    a = sorted(readLine_int_list(),reverse=True)
    a.append(-1)
    pair = []
    ans = 0
    t = 1
    
    for i in range(n):
        
        if a[i] == a[i+1]:
            t += 1
        else:
            if t > 1:
                pair.append(a[i])
                if len(pair) == 2:
                    ans = pair[0] * pair[1]
                    break
            t = 1
        
        if t > 3:
            if pair:
                ans = max(a[i-1]*a[i], pair[0]*a[i])
            else:
                ans = a[i]**2
            break

        
        

    print(ans)


if __name__ == '__main__':
    main()
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))

use_1 = 0
use_2 = 0
for i in set(a):
    can = a.count(i) // 2
    if can == 1:
        if use_1 < i:
            use_2 = use_1
            use_1 = i
    elif can > 1:
         use_1 = max(use_1, i)
         use_2 = max(use_2, i)

print((use_1*use_2))


# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split()))
a.sort()
a = a[::-1]
tobasu = 0
one = 0
two = 0
for i in range(len(a) - 1):
    if tobasu == 1:
        tobasu = 0
        continue
    if a[i] == a[i + 1] and one == 0:
        tobasu = 1
        one = a[i]
    elif a[i] == a[i + 1] and one != 0 and two == 0:
        two = a[i]
        break
print((one * two))
# Original solution
import collections
N = int(eval(input()))
A = list(map(int, input().split()))


dic = collections.defaultdict(int)

for x in A:
    dic[x] += 1

dic = list(dic.items())
dic = [x for x in dic if x[1] >= 2]
dic = sorted(dic, reverse=True, key=lambda x: x[0])

if len(dic) >= 2:
    if dic[0][1] >= 4:
        print((dic[0][0] * dic[0][0]))
    else:
        print((dic[0][0] * dic[1][0]))
else:
    print((0))


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

table = collections.defaultdict(int)
hq = [0, 0]
for x in A:
    table[x] += 1
    if table[x] == 2:
        heapq.heappush(hq, -x)
        table[x] = 0
print((heapq.heappop(hq) * heapq.heappop(hq)))
# Original solution
N = int(eval(input()))

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

d = {}
for i in range(N):
    if A[i] not in d:
        d[A[i]] = 0
    d[A[i]] += 1


ans = 0
for k in d:
    if d[k] >= 4:
        ans = max(ans, k ** 2)
    
    if d[k] >= 2:
        for l in d:
            if k == l: continue
            elif d[l] >= 2:
                ans = max(ans, k * l)

print(ans) 

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

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

d = {}
for i in range(N):
    if A[i] not in d:
        d[A[i]] = 0
    d[A[i]] += 1


ans = {0}
s1 = [k for k, v in list(d.items()) if v >= 4]
if len(s1) > 0:
    s1.sort()
    ans.add(s1[-1] ** 2)

s2 = [k for k, v in list(d.items()) if v >= 2]
if len(s2) >= 2:
    s2.sort()
    ans.add(s2[-1] * s2[-2])

print((max(ans)))
# Original solution
from collections import Counter


N = int(eval(input()))
c = Counter(list(map(int, input().split())))
usables = sorted([(k, v) for k, v in list(c.items()) if v >= 2])
if len(usables) <= 1:
    print((0))
else:
    if usables[-1][1] >= 4:
        print((usables[-1][0] ** 2))
    else:
        print((usables[-1][0] * usables[-2][0]))


# Optimized solution
from collections import Counter


def solve():
    N = int(eval(input()))
    c = Counter(list(map(int, input().split())))
    usables = sorted([k for k, v in list(c.items()) if v > 1])

    if len(usables) == 0:
        return 0
    else:
        ans = usables[-1]
        if c[ans] > 3:
            return ans ** 2
        elif len(usables) > 1:
            usables.pop()
            return ans * usables[-1]
        else:
            return 0


print((solve()))
# Original solution
#! /usr/bin/env python3

N = int(eval(input()))
L = sorted(map(int, input().split()))[::-1]
a = 0
b = 0
while L:
    t = L.pop(0)
    if a == t:
        break
    else:
        a = t
while L:
    t = L.pop(0)
    if b == t:
        break
    else:
        b = t
    
print((a*b))

# Optimized solution
#! /usr/bin/env python3

def main():
    N = int(eval(input()))
    L = sorted(map(int, input().split()))[::-1]
    a = b = c = 0
    while c < len(L):
        t = L[c]
        c += 1
        if a == t:
            break
        else:
            a = t
    while c < len(L):
        t = L[c]
        c += 1
        if b == t:
            break
        else:
            b = t
    print((a*b))
    
if __name__ == '__main__':
    main()
# Original solution
#! /usr/bin/env python3

def main():
    N = int(eval(input()))
    L = sorted(map(int, input().split()))[::-1]
    a = b = c = 0
    while c < len(L):
        t = L[c]
        c += 1
        if a == t:
            break
        else:
            a = t
    while c < len(L):
        t = L[c]
        c += 1
        if b == t:
            break
        else:
            b = t
    print((a*b))
    
if __name__ == '__main__':
    main()

# Optimized solution
#! /usr/bin/env python3

def main():
    N = int(eval(input()))
    L = sorted(map(int, input().split()))
    a = b = 0
    c = len(L) - 1
    while c > -1:
        t = L[c]
        c -= 1
        if a == t:
            break
        else:
            a = t
    while c > -1:
        t = L[c]
        c -= 1
        if b == t:
            break
        else:
            b = t
    print((a*b))
    
if __name__ == '__main__':
    main()
# Original solution
from collections import Counter
n=eval(input())
a=list(map(int,input().split()))
a=Counter(a)

f,t=[],[]
for k in a:
    if a[k]>=4:
        f.append(k)
    if a[k]>=2:
        t.append(k)
# print('f:',f)
# print('t:',t)
ans1=0
for ff in f:
    ans1=max(ans1,ff**2)
ans2=0
t.sort(reverse=True)
if len(t)>=2:
    ans2=t[0]*t[1]
print((max(ans1,ans2)))



# Optimized solution
from collections import Counter
n=int(eval(input()))
a=list(map(int,input().split()))
c=Counter(a)
l4,l2=[],[]
for k,v in list(c.items()):
    if v>=4:l4.append(k)
    if v>=2:l2.append(k)
l4.sort(reverse=True)
l2.sort(reverse=True)
if len(l4)<=2:l4+=[0,0]
if len(l2)<=2:l2+=[0,0]
print((max(l4[0]*l4[1],l4[0]*l2[0],l2[0]*l2[1])))
# Original solution
import collections
N = int(eval(input()))
A = list(map(int,input().split()))
c = collections.Counter(A)
c_l = c.most_common()
l = []
for e in c_l:
    if e[1] >= 4:
        l.append(e[0])
        l.append(e[0])
    elif e[1] >= 2:
        l.append(e[0])
l.sort()
if len(l) >= 2:
    print((l[-1]*l[-2]))
else:
    print((0))

# Optimized solution
from collections import Counter
N = int(eval(input()))
A = list(map(int,input().split()))
c = Counter(A)
op = []
for a, cnt in list(c.items()):
    for _ in range(cnt // 2):
        op.append(a)
op.sort(reverse=True)
if len(op) < 2:
    print((0))
else:
    print((op[0]*op[1]))
# Original solution
# import bisect
from collections import Counter, deque
# from copy import copy, deepcopy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np
# from operator import xor
import sys

sys.setrecursionlimit(10 ** 5 + 10)


# input = sys.stdin.readline

def resolve():
    N = int(eval(input()))
    A = list(map(int, input().split()))

    AA = Counter(A).most_common()

    ls = []
    for i in range(len(AA)):
        if AA[i][1] >= 2:
            ls.append(AA[i])
        else:
            break

    ls=sorted(ls, key=lambda x: x[0])

    try:
        ans = ls[-1][0] * ls[-2][0]
        for i in reversed(list(range(len(ls)))):
            if ls[i][1] >= 4:
                ans = max(ans, ls[i][0] ** 2)
        print(ans)
    except:
        print((0))


resolve()

# Optimized solution
# import bisect
from collections import Counter, deque
# from copy import copy, deepcopy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np
# from operator import xor
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline

def resolve():

    N=int(eval(input()))
    A=sorted(list(map(int,input().split())),reverse=True)
    temp=-1
    maxans=0
    AA=Counter(A)
    for (i,j) in list(AA.items()):
        if j>=4:
            maxans=max(i**2,maxans)
        if j>=2:
            if temp>=0:
                maxans=max(maxans,temp*i)
            temp=max(i,temp)
    print(maxans)




resolve()
# Original solution
# import bisect
from collections import Counter, deque
# from copy import copy, deepcopy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np
# from operator import xor
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline

def resolve():

    N=int(eval(input()))
    A=sorted(list(map(int,input().split())),reverse=True)
    temp=-1
    maxans=0
    AA=Counter(A)
    for (i,j) in list(AA.items()):
        if j>=4:
            maxans=max(i**2,maxans)
        if j>=2:
            if temp>=0:
                maxans=max(maxans,temp*i)
            temp=max(i,temp)
    print(maxans)




resolve()

# Optimized solution
from collections import Counter, deque, OrderedDict
# from copy import copy, deepcopy
# from functools import reduce
# from heapq import heapify, heappop, heappush
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import statistics # Pythonのみ
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()


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

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


resolve()
# Original solution
N = int(eval(input()))
A = list(map(int,input().split()))
B = set(A)
C = sorted([i for i in B if A.count(i) // 2 >= 1],reverse = True)

ans = 0
m = 0
n = 0

if len(C) == 0:
 ans = 0
 
elif A.count(C[0]) >= 4:
  m = C[0]
  ans = m ** 2

elif len(C) > 1:
  m = C[0]
  n = C[1]
  ans = m * n

print(ans)

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

edge = []

for i in range(1,N):
  if A[i] == A[i - 1] and A[i] not in edge:
    edge.append(A[i])
  elif A[i] == A[i - 3]:
    edge.append(A[i])
  
  if len(edge) == 2:
    break
    
if len(edge) <= 1:
  print((0))
else:
  print((edge[0] * edge[1]))
# Original solution
#!/usr/bin/env python3

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

ans = 0 
d = {}
for i in a:
    if i not in d:
        d[i] = 1 
    else:
        d[i] += 1

d = sorted(list(d.items()), key=lambda x:x[0], reverse=True)
area = 1 
cnt = 0 
allone = True
for i in d:
    if 1 < i[1] < 4:
        allone = False
        if cnt == 2:
            break
        area *= i[0]
        cnt += 1
    elif i[1] >= 4:
        allone = False
        if cnt == 0:
            area = i[0]*i[0]
            break
        else:
            if cnt == 2:
                break
            area *= i[0]
            cnt += 1

if allone:
    print((0))
else:
    print(area)


# Optimized solution
#!/usr/bin/env python3

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

ans = 0 
d = {}
for i in a:
    if i not in d:
        d[i] = 1 
    else:
        d[i] += 1

d = sorted(list(d.items()), key=lambda x:x[0], reverse=True)
area = 1 
cnt = 0 
allone = True
for i in d:
    if i[1] != 1:
        allone = False
        if i[1] >= 4:
            if cnt == 0:
                area = i[0]*i[0]
                break
            else:
                if cnt == 2:
                    break
                area *= i[0]
                cnt += 1
        else:
            if cnt == 2:
                break
            area *= i[0]
            cnt += 1

if allone:
    print((0))
else:
    print(area)