import sys

sys.setrecursionlimit(10**9)

N = int(eval(input()))

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

A = sorted(A, reverse=True)





def chouhoukei(count, ans, num):

    if count == 4:

        return ans

    else:

        if num >= N - 1:

            return 0

        if A[num] == A[num + 1]:

            return chouhoukei(count + 2, ans * A[num], num + 2)

        else:

            return chouhoukei(count, ans, num + 1)





print((chouhoukei(0, 1, 0)))

from collections import Counter



n = int(eval(input()))

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

cnt_A = Counter(A)

# print(cnt_A)



kouho = []



ans = 0



for key in cnt_A:

    if cnt_A[key] >= 2:

        kouho.append(key)

    if cnt_A[key] >= 4:

        ans = max(ans, key ** 2)



if len(kouho) < 2:

    print(ans)

    exit()



kouho.sort()

ans = max(ans, kouho[-1] * kouho[-2])

print(ans)

import sys

sys.setrecursionlimit(10**9)
N = int(eval(input()))
A = list(map(int, input().split()))
A = sorted(A, reverse=True)


def chouhoukei(count, ans, num):
    if count == 4:
        return ans
    else:
        if num >= N - 1:
            return 0
        if A[num] == A[num + 1]:
            return chouhoukei(count + 2, ans * A[num], num + 2)
        else:
            return chouhoukei(count, ans, num + 1)


print((chouhoukei(0, 1, 0)))

from collections import Counter

n = int(eval(input()))
A = list(map(int, input().split()))
cnt_A = Counter(A)
# print(cnt_A)
kouho = []
ans = 0
for key in cnt_A:
    if cnt_A[key] >= 2:
        kouho.append(key)
    if cnt_A[key] >= 4:
        ans = max(ans, key**2)
if len(kouho) < 2:
    print(ans)
    exit()
kouho.sort()
ans = max(ans, kouho[-1] * kouho[-2])
print(ans)

-import sys +from collections import Counter -sys.setrecursionlimit(10**9) -N = int(eval(input())) +n = int(eval(input())) -A = sorted(A, reverse=True) - - -def chouhoukei(count, ans, num): -    if count == 4: -        return ans -    else: -        if num >= N - 1: -            return 0 -        if A[num] == A[num + 1]: -            return chouhoukei(count + 2, ans * A[num], num + 2) -        else: -            return chouhoukei(count, ans, num + 1) - - -print((chouhoukei(0, 1, 0))) +cnt_A = Counter(A) +# print(cnt_A) +kouho = [] +ans = 0 +for key in cnt_A: +    if cnt_A[key] >= 2: +        kouho.append(key) +    if cnt_A[key] >= 4: +        ans = max(ans, key**2) +if len(kouho) < 2: +    print(ans) +    exit() +kouho.sort() +ans = max(ans, kouho[-1] * kouho[-2]) +print(ans)