from collections import defaultdict

n = int(eval(input()))

a_list = [int(x) for x in input().split()]

d = defaultdict(int)

for a in a_list:

    d[a] += 1

temp_list = sorted([(k, v) for k, v in list(d.items()) if v >= 2], reverse=True)

if len(temp_list) >= 2:

    print((temp_list[0][0] ** 2 if temp_list[0][1] >= 4 else temp_list[0][0] * temp_list[1][0]))

else:

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

a_list = sorted([int(x) for x in input().split()], reverse=True)

ans = 0

temp = 0

count = 0

e = None

for i in range(n):

    if a_list[i] == temp:

        count += 1

        if count == 2:

            if e is None:

                e = temp

                count -= 2

            else:

                ans = e * temp

                break

    else:

        temp = a_list[i]

        count = 1

print(ans)
from collections import defaultdict

n = int(eval(input()))
a_list = [int(x) for x in input().split()]
d = defaultdict(int)
for a in a_list:
    d[a] += 1
temp_list = sorted([(k, v) for k, v in list(d.items()) if v >= 2], reverse=True)
if len(temp_list) >= 2:
    print(
        (
            temp_list[0][0] ** 2
            if temp_list[0][1] >= 4
            else temp_list[0][0] * temp_list[1][0]
        )
    )
else:
    print((0))

n = int(eval(input()))
a_list = sorted([int(x) for x in input().split()], reverse=True)
ans = 0
temp = 0
count = 0
e = None
for i in range(n):
    if a_list[i] == temp:
        count += 1
        if count == 2:
            if e is None:
                e = temp
                count -= 2
            else:
                ans = e * temp
                break
    else:
        temp = a_list[i]
        count = 1
print(ans)

-from collections import defaultdict - -a_list = [int(x) for x in input().split()] -d = defaultdict(int) -for a in a_list: -    d[a] += 1 -temp_list = sorted([(k, v) for k, v in list(d.items()) if v >= 2], reverse=True) -if len(temp_list) >= 2: -    print( -        ( -            temp_list[0][0] ** 2 -            if temp_list[0][1] >= 4 -            else temp_list[0][0] * temp_list[1][0] -        ) -    ) -else: -    print((0)) +a_list = sorted([int(x) for x in input().split()], reverse=True) +ans = 0 +temp = 0 +count = 0 +e = None +for i in range(n): +    if a_list[i] == temp: +        count += 1 +        if count == 2: +            if e is None: +                e = temp +                count -= 2 +            else: +                ans = e * temp +                break +    else: +        temp = a_list[i] +        count = 1 +print(ans)