from collections import Counter



N = int(eval(input()))

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



ans = [0, 0]

for k in sorted(list(A.keys()), reverse=True):

    if A[k] >= 2:

        ans.append(k)

    if A[k] >= 4:

        ans.append(k)

ans = sorted(ans)

print((ans[-1]*ans[-2]))

from collections import Counter



N = int(eval(input()))

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

A = {k: v for k, v in list(A.items()) if v >= 2}

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

A.extend([(0, 0), (0, 0)])

if A[0][1] >= 4:

    print((A[0][0]**2))

else:

    print((A[0][0]*A[1][0]))

from collections import Counter

N = int(eval(input()))
A = Counter(list(map(int, input().split())))
ans = [0, 0]
for k in sorted(list(A.keys()), reverse=True):
    if A[k] >= 2:
        ans.append(k)
    if A[k] >= 4:
        ans.append(k)
ans = sorted(ans)
print((ans[-1] * ans[-2]))

from collections import Counter

N = int(eval(input()))
A = Counter(list(map(int, input().split())))
A = {k: v for k, v in list(A.items()) if v >= 2}
A = sorted(list(A.items()), key=lambda x: x[0], reverse=True)
A.extend([(0, 0), (0, 0)])
if A[0][1] >= 4:
    print((A[0][0] ** 2))
else:
    print((A[0][0] * A[1][0]))

-ans = [0, 0] -for k in sorted(list(A.keys()), reverse=True): -    if A[k] >= 2: -        ans.append(k) -    if A[k] >= 4: -        ans.append(k) -ans = sorted(ans) -print((ans[-1] * ans[-2])) +A = {k: v for k, v in list(A.items()) if v >= 2} +A = sorted(list(A.items()), key=lambda x: x[0], reverse=True) +A.extend([(0, 0), (0, 0)]) +if A[0][1] >= 4: +    print((A[0][0] ** 2)) +else: +    print((A[0][0] * A[1][0]))