from collections import Counter

N = int(eval(input()))

Ac = Counter(list(map(int, input().split())))

sticks = sorted({k:v for k, v in list(Ac.items()) if v >= 2}.items())[::-1]

if len(sticks) == 0:

    print((0))

else:

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

        print((sticks[0][0]**2))

    else:

        print((sticks[0][0]*sticks[1][0]))

from collections import Counter

N = int(eval(input()))

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

Ac = Counter(Alist)

length_list = sorted(list(Ac.keys()), reverse=True)

can_use = []

for l in length_list:

    if Ac[l] >= 4:

        if can_use:

            print((can_use[0]*l))

            exit()

        else:

            print((l**2))

            exit()

    elif Ac[l] >= 2:

        if can_use:

            print((can_use[0]*l))

            exit()

        else:

            can_use.append(l)



print((0))
from collections import Counter

N = int(eval(input()))
Ac = Counter(list(map(int, input().split())))
sticks = sorted({k: v for k, v in list(Ac.items()) if v >= 2}.items())[::-1]
if len(sticks) == 0:
    print((0))
else:
    if sticks[0][1] >= 4:
        print((sticks[0][0] ** 2))
    else:
        print((sticks[0][0] * sticks[1][0]))

from collections import Counter

N = int(eval(input()))
Alist = list(map(int, input().split()))
Ac = Counter(Alist)
length_list = sorted(list(Ac.keys()), reverse=True)
can_use = []
for l in length_list:
    if Ac[l] >= 4:
        if can_use:
            print((can_use[0] * l))
            exit()
        else:
            print((l**2))
            exit()
    elif Ac[l] >= 2:
        if can_use:
            print((can_use[0] * l))
            exit()
        else:
            can_use.append(l)
print((0))

-Ac = Counter(list(map(int, input().split()))) -sticks = sorted({k: v for k, v in list(Ac.items()) if v >= 2}.items())[::-1] -if len(sticks) == 0: -    print((0)) -else: -    if sticks[0][1] >= 4: -        print((sticks[0][0] ** 2)) -    else: -        print((sticks[0][0] * sticks[1][0])) +Alist = list(map(int, input().split())) +Ac = Counter(Alist) +length_list = sorted(list(Ac.keys()), reverse=True) +can_use = [] +for l in length_list: +    if Ac[l] >= 4: +        if can_use: +            print((can_use[0] * l)) +            exit() +        else: +            print((l**2)) +            exit() +    elif Ac[l] >= 2: +        if can_use: +            print((can_use[0] * l)) +            exit() +        else: +            can_use.append(l) +print((0))