N = int(eval(input()))

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



pair = []

unpair = set()

for a in A:

    if a in unpair:

        pair.append(a)

        unpair.remove(a)

    else:

        unpair.add(a)



pair.sort()

pair.reverse()

if len(pair) <= 1:

    ans = 0

else:

    ans = pair[0] * pair[1]

print(ans)
with open(0) as f:

    N, *A = list(map(int, f.read().split()))



pair = []

unpair = set()

for a in A:

    if a in unpair:

        unpair.remove(a)

        pair.append(a)

    else:

        unpair.add(a)

pair.sort()

print((pair.pop()*pair.pop() if len(pair) > 1 else 0))
N = int(eval(input()))
A = [int(x) for x in input().split()]
pair = []
unpair = set()
for a in A:
    if a in unpair:
        pair.append(a)
        unpair.remove(a)
    else:
        unpair.add(a)
pair.sort()
pair.reverse()
if len(pair) <= 1:
    ans = 0
else:
    ans = pair[0] * pair[1]
print(ans)

with open(0) as f:
    N, *A = list(map(int, f.read().split()))
pair = []
unpair = set()
for a in A:
    if a in unpair:
        unpair.remove(a)
        pair.append(a)
    else:
        unpair.add(a)
pair.sort()
print((pair.pop() * pair.pop() if len(pair) > 1 else 0))

-N = int(eval(input())) -A = [int(x) for x in input().split()] +with open(0) as f: +    N, *A = list(map(int, f.read().split())) +        unpair.remove(a) -        unpair.remove(a) -pair.reverse() -if len(pair) <= 1: -    ans = 0 -else: -    ans = pair[0] * pair[1] -print(ans) +print((pair.pop() * pair.pop() if len(pair) > 1 else 0))