N = int(eval(input()))

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



import collections

ans = 0

c = collections.Counter(A)

lis = []

for k,v in list(c.items()):

  if v>=2:

    lis.append(k)

  if v>=4:

    lis.append(k)

if len(lis)>=2:

  lis.sort()

  ans = lis[-1]*lis[-2]

print(ans)



#print(*ans, sep='\n')

from collections import Counter

def solve():

    ans = 0

    N = int(eval(input()))

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

    C = Counter(A)

    D = [[0,0],[0,0]]

    for k,v in list(C.items()):

        if v>=2:

            D.append([k,v])

    D.sort(reverse=True)

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

        return D[0][0]**2

    return D[0][0]*D[1][0]

print((solve()))
N = int(eval(input()))
A = list(map(int, input().split()))
import collections

ans = 0
c = collections.Counter(A)
lis = []
for k, v in list(c.items()):
    if v >= 2:
        lis.append(k)
    if v >= 4:
        lis.append(k)
if len(lis) >= 2:
    lis.sort()
    ans = lis[-1] * lis[-2]
print(ans)
# print(*ans, sep='\n')

from collections import Counter


def solve():
    ans = 0
    N = int(eval(input()))
    A = list(map(int, input().split()))
    C = Counter(A)
    D = [[0, 0], [0, 0]]
    for k, v in list(C.items()):
        if v >= 2:
            D.append([k, v])
    D.sort(reverse=True)
    if D[0][1] >= 4:
        return D[0][0] ** 2
    return D[0][0] * D[1][0]


print((solve()))

-N = int(eval(input())) -A = list(map(int, input().split())) -import collections +from collections import Counter -ans = 0 -c = collections.Counter(A) -lis = [] -for k, v in list(c.items()): -    if v >= 2: -        lis.append(k) -    if v >= 4: -        lis.append(k) -if len(lis) >= 2: -    lis.sort() -    ans = lis[-1] * lis[-2] -print(ans) -# print(*ans, sep='\n') + +def solve(): +    ans = 0 +    N = int(eval(input())) +    A = list(map(int, input().split())) +    C = Counter(A) +    D = [[0, 0], [0, 0]] +    for k, v in list(C.items()): +        if v >= 2: +            D.append([k, v]) +    D.sort(reverse=True) +    if D[0][1] >= 4: +        return D[0][0] ** 2 +    return D[0][0] * D[1][0] + + +print((solve()))