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)))



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])))





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)))

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])))

-n = eval(input()) +n = int(eval(input())) -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))) +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])))