import collections



N = int(eval(input()))

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

A = sorted(A)[::-1]



s = collections.Counter(A)

res = 1

count = 0



for i in sorted(list(set(A)))[::-1]:

    if 4 <= s[i] and count != 1:

        res *= i

        res *= i

        count += 2

    elif 2 <= s[i]:

        res *= i 

        count += 1



    if count == 2:

        break



if count == 2:

    print(res)

else:

    print((0))

    



from collections import Counter

N = int(eval(input()))

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



counter = Counter(A)

res =[]



for word,cnt in counter.most_common():

    if 4 <= cnt:

        res.append(word)

        res.append(word)

    elif 2 <= cnt:

        res.append(word)



res = sorted(res)[::-1]

if len(res) < 2:

    print((0))

else:

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

    

import collections

N = int(eval(input()))
A = list(map(int, input().split()))
A = sorted(A)[::-1]
s = collections.Counter(A)
res = 1
count = 0
for i in sorted(list(set(A)))[::-1]:
    if 4 <= s[i] and count != 1:
        res *= i
        res *= i
        count += 2
    elif 2 <= s[i]:
        res *= i
        count += 1
    if count == 2:
        break
if count == 2:
    print(res)
else:
    print((0))

from collections import Counter

N = int(eval(input()))
A = list(map(int, input().split()))
counter = Counter(A)
res = []
for word, cnt in counter.most_common():
    if 4 <= cnt:
        res.append(word)
        res.append(word)
    elif 2 <= cnt:
        res.append(word)
res = sorted(res)[::-1]
if len(res) < 2:
    print((0))
else:
    print((res[0] * res[1]))

-import collections +from collections import Counter -A = sorted(A)[::-1] -s = collections.Counter(A) -res = 1 -count = 0 -for i in sorted(list(set(A)))[::-1]: -    if 4 <= s[i] and count != 1: -        res *= i -        res *= i -        count += 2 -    elif 2 <= s[i]: -        res *= i -        count += 1 -    if count == 2: -        break -if count == 2: -    print(res) +counter = Counter(A) +res = [] +for word, cnt in counter.most_common(): +    if 4 <= cnt: +        res.append(word) +        res.append(word) +    elif 2 <= cnt: +        res.append(word) +res = sorted(res)[::-1] +if len(res) < 2: +    print((0)) -    print((0)) +    print((res[0] * res[1]))