from collections import Counter

N = int(eval(input()))

A = [int(Ai) for Ai in input().split()]

c = Counter(A).most_common()

c.sort(key=lambda x: x[0], reverse=True)

e1 = None

result = None

for k, v in c:

    if e1 is None and v >= 4:

        result = k**2

        break

    elif v >= 2:

        if e1 is None:

            e1 = k

        else:

            result = e1 * k

            break

if result is not None:

    print(result)

else:

    print((0))
N = int(eval(input()))

A = sorted([int(Ai) for Ai in input().split()], reverse=True)

x, y = 0, 0

current = A[0]

for Ai in A[1:]:

    if current is None or current != Ai:

        current = Ai

    else:

        if x == 0:

            x = current

            current = None

        else:

            y = current

            break

print((x * y))
from collections import Counter

N = int(eval(input()))
A = [int(Ai) for Ai in input().split()]
c = Counter(A).most_common()
c.sort(key=lambda x: x[0], reverse=True)
e1 = None
result = None
for k, v in c:
    if e1 is None and v >= 4:
        result = k**2
        break
    elif v >= 2:
        if e1 is None:
            e1 = k
        else:
            result = e1 * k
            break
if result is not None:
    print(result)
else:
    print((0))

N = int(eval(input()))
A = sorted([int(Ai) for Ai in input().split()], reverse=True)
x, y = 0, 0
current = A[0]
for Ai in A[1:]:
    if current is None or current != Ai:
        current = Ai
    else:
        if x == 0:
            x = current
            current = None
        else:
            y = current
            break
print((x * y))

-from collections import Counter - -A = [int(Ai) for Ai in input().split()] -c = Counter(A).most_common() -c.sort(key=lambda x: x[0], reverse=True) -e1 = None -result = None -for k, v in c: -    if e1 is None and v >= 4: -        result = k**2 -        break -    elif v >= 2: -        if e1 is None: -            e1 = k +A = sorted([int(Ai) for Ai in input().split()], reverse=True) +x, y = 0, 0 +current = A[0] +for Ai in A[1:]: +    if current is None or current != Ai: +        current = Ai +    else: +        if x == 0: +            x = current +            current = None -            result = e1 * k +            y = current -if result is not None: -    print(result) -else: -    print((0)) +print((x * y))