import collections



N = int(eval(input()))

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



dic = collections.Counter(A).most_common()



tmp = []

check = 0



dic.sort(reverse=True)



for a, b in dic:

    if b >= 2:

        check += 1

        tmp.append(a)

        if b>= 4:

            break

        if check == 2:

            break



if len(tmp) == 0:

    print((0))

elif len(tmp) == 1:

    print((tmp[0]*tmp[0]))

else:

    print((tmp[0] * tmp[1]))
import collections



N = int(eval(input()))

a = [int(i) for i in input().split()]

check = []

dict = collections.Counter(a)

for a, b in list(dict.items()):

    if b >= 2:

        check.append(a)



if len(check) >=2:

    check.sort()

    if dict[check[-1]] >= 4:

        print((check[-1] ** 2))

    else:

        print((check[-1] * check[-2]))

elif len(check) == 1:

    if dict[check[-1]] >= 4:

        print((check[-1] ** 2))

    else:

        print((0))

else:

    print((0))
import collections

N = int(eval(input()))
A = [int(i) for i in input().split()]
dic = collections.Counter(A).most_common()
tmp = []
check = 0
dic.sort(reverse=True)
for a, b in dic:
    if b >= 2:
        check += 1
        tmp.append(a)
        if b >= 4:
            break
        if check == 2:
            break
if len(tmp) == 0:
    print((0))
elif len(tmp) == 1:
    print((tmp[0] * tmp[0]))
else:
    print((tmp[0] * tmp[1]))

import collections

N = int(eval(input()))
a = [int(i) for i in input().split()]
check = []
dict = collections.Counter(a)
for a, b in list(dict.items()):
    if b >= 2:
        check.append(a)
if len(check) >= 2:
    check.sort()
    if dict[check[-1]] >= 4:
        print((check[-1] ** 2))
    else:
        print((check[-1] * check[-2]))
elif len(check) == 1:
    if dict[check[-1]] >= 4:
        print((check[-1] ** 2))
    else:
        print((0))
else:
    print((0))

-A = [int(i) for i in input().split()] -dic = collections.Counter(A).most_common() -tmp = [] -check = 0 -dic.sort(reverse=True) -for a, b in dic: +a = [int(i) for i in input().split()] +check = [] +dict = collections.Counter(a) +for a, b in list(dict.items()): -        check += 1 -        tmp.append(a) -        if b >= 4: -            break -        if check == 2: -            break -if len(tmp) == 0: +        check.append(a) +if len(check) >= 2: +    check.sort() +    if dict[check[-1]] >= 4: +        print((check[-1] ** 2)) +    else: +        print((check[-1] * check[-2])) +elif len(check) == 1: +    if dict[check[-1]] >= 4: +        print((check[-1] ** 2)) +    else: +        print((0)) +else: -elif len(tmp) == 1: -    print((tmp[0] * tmp[0])) -else: -    print((tmp[0] * tmp[1]))