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

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

-import collections +from collections import Counter -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])) +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)) -    print((0)) +    print((op[0] * op[1]))