from collections import defaultdict



n = int(eval(input()))

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

d = defaultdict(int)

l = []

for key in A:

  d[key] += 1

  if d[key] == 2:

    l.append(key)

    d[key] = 0

if len(l) < 2:

  print((0))

else:

  l.sort(reverse=True)

  print((l[0]*l[1]))
from collections import Counter



n = int(eval(input()))

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

C = Counter(A)

L = []

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

  if v >= 2:

    L.append(k)

  if v >= 4:

    L.append(k)

if len(L) < 2:

  print((0))

else:

  L.sort()

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

  print(ans)
from collections import defaultdict

n = int(eval(input()))
A = list(map(int, input().split()))
d = defaultdict(int)
l = []
for key in A:
    d[key] += 1
    if d[key] == 2:
        l.append(key)
        d[key] = 0
if len(l) < 2:
    print((0))
else:
    l.sort(reverse=True)
    print((l[0] * l[1]))

from collections import Counter

n = int(eval(input()))
A = list(map(int, input().split()))
C = Counter(A)
L = []
for k, v in list(C.items()):
    if v >= 2:
        L.append(k)
    if v >= 4:
        L.append(k)
if len(L) < 2:
    print((0))
else:
    L.sort()
    ans = L[-1] * L[-2]
    print(ans)

-from collections import defaultdict +from collections import Counter -d = defaultdict(int) -l = [] -for key in A: -    d[key] += 1 -    if d[key] == 2: -        l.append(key) -        d[key] = 0 -if len(l) < 2: +C = Counter(A) +L = [] +for k, v in list(C.items()): +    if v >= 2: +        L.append(k) +    if v >= 4: +        L.append(k) +if len(L) < 2: -    l.sort(reverse=True) -    print((l[0] * l[1])) +    L.sort() +    ans = L[-1] * L[-2] +    print(ans)