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

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

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

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

+import heapq -dic = collections.defaultdict(int) +table = collections.defaultdict(int) +hq = [0, 0] -    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)) +    table[x] += 1 +    if table[x] == 2: +        heapq.heappush(hq, -x) +        table[x] = 0 +print((heapq.heappop(hq) * heapq.heappop(hq)))