from collections import Counter

n=eval(input())

a=sorted(list(map(int,input().split())))[::-1]

ca=Counter(a).most_common()

if ca[1][1]<2:

    if ca[0][1]<4:print((0))

    else:print((ca[0][0]**2))

else:

    l=[]

    for i,j in ca:

        for _ in range(j//2):l.append(i)

    l.sort()

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

n=eval(input())

a=sorted(list(map(int,input().split())))[::-1]

ca=Counter(a).most_common()

if ca[1][1]<2:

    if ca[0][1]<4:print((0))

    else:print((ca[0][0]**2))

else:

    l=[]

    for i,j in ca:

        if j<2:break

        elif j<4:l.append(i)

        else:

            l.append(i)

            l.append(i)

    l.sort()

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

n = eval(input())
a = sorted(list(map(int, input().split())))[::-1]
ca = Counter(a).most_common()
if ca[1][1] < 2:
    if ca[0][1] < 4:
        print((0))
    else:
        print((ca[0][0] ** 2))
else:
    l = []
    for i, j in ca:
        for _ in range(j // 2):
            l.append(i)
    l.sort()
    print((l[-1] * l[-2]))

from collections import Counter

n = eval(input())
a = sorted(list(map(int, input().split())))[::-1]
ca = Counter(a).most_common()
if ca[1][1] < 2:
    if ca[0][1] < 4:
        print((0))
    else:
        print((ca[0][0] ** 2))
else:
    l = []
    for i, j in ca:
        if j < 2:
            break
        elif j < 4:
            l.append(i)
        else:
            l.append(i)
            l.append(i)
    l.sort()
    print((l[-1] * l[-2]))

-        for _ in range(j // 2): +        if j < 2: +            break +        elif j < 4: +            l.append(i) +        else: +            l.append(i)