from collections import Counter



n = int(eval(input()))

A = Counter(list(map(int, input().split())))

A = sorted(A.most_common(), reverse=True)

rods = []

for a in A:

    if a[1] >= 4:

        rods.append(a[0])

        rods.append(a[0])

        break

    if a[1] >= 2:

        rods.append(a[0])

    if len(rods) == 2:

        break

if len(rods) >= 2:

    ans = rods[0]*rods[1]

else:

    ans = 0

print(ans)

from collections import defaultdict



n = int(eval(input()))

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

C = defaultdict(int)

for a in A:

    C[a] += 1

C = sorted(list(C.items()), key=lambda x: x[0], reverse=True)

rods = []

for k, v in C:

    if v >= 4:

        rods.append(k)

        rods.append(k)

        break

    if v >= 2:

        rods.append(k)

    if len(rods) == 2:

        break

if len(rods) >= 2:

    ans = rods[0]*rods[1]

else:

    ans = 0

print(ans)

from collections import Counter

n = int(eval(input()))
A = Counter(list(map(int, input().split())))
A = sorted(A.most_common(), reverse=True)
rods = []
for a in A:
    if a[1] >= 4:
        rods.append(a[0])
        rods.append(a[0])
        break
    if a[1] >= 2:
        rods.append(a[0])
    if len(rods) == 2:
        break
if len(rods) >= 2:
    ans = rods[0] * rods[1]
else:
    ans = 0
print(ans)

from collections import defaultdict

n = int(eval(input()))
A = list(map(int, input().split()))
C = defaultdict(int)
for a in A:
    C[a] += 1
C = sorted(list(C.items()), key=lambda x: x[0], reverse=True)
rods = []
for k, v in C:
    if v >= 4:
        rods.append(k)
        rods.append(k)
        break
    if v >= 2:
        rods.append(k)
    if len(rods) == 2:
        break
if len(rods) >= 2:
    ans = rods[0] * rods[1]
else:
    ans = 0
print(ans)

-from collections import Counter +from collections import defaultdict -A = Counter(list(map(int, input().split()))) -A = sorted(A.most_common(), reverse=True) +A = list(map(int, input().split())) +C = defaultdict(int) +for a in A: +    C[a] += 1 +C = sorted(list(C.items()), key=lambda x: x[0], reverse=True) -for a in A: -    if a[1] >= 4: -        rods.append(a[0]) -        rods.append(a[0]) +for k, v in C: +    if v >= 4: +        rods.append(k) +        rods.append(k) -    if a[1] >= 2: -        rods.append(a[0]) +    if v >= 2: +        rods.append(k)