from collections import Counter



N = int(eval(input()))

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



counter = sorted(

    list(Counter(A).items()),

    key=lambda x:x[0],

    reverse=True)



ans = 1

cnt = 0

for length, num in counter:

    if cnt >= 2:

        break

    if num >= 4 and cnt == 0:

        print((length**2))

        exit()

    if num >= 2:

        ans *= length

        cnt += 1



if cnt == 2:

    print(ans)

else:

    print((0))

from collections import Counter



n = int(eval(input()))

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



# 長さと個数の辞書

length_num = Counter(A)

# 長い順からの長さのリスト

lengths = sorted(list(length_num.keys()), reverse=True)



ans = 0

sides = []



# 長い辺の順にループ

for l in lengths:

  if length_num[l] >= 4:

    ans = max(ans, l * l)

  if length_num[l] >= 2:

    sides.append(l)

  if len(sides) == 2:

    ans = max(ans, sides[0] * sides[1])

    break



print(ans)

from collections import Counter

N = int(eval(input()))
A = list(map(int, input().split()))
counter = sorted(list(Counter(A).items()), key=lambda x: x[0], reverse=True)
ans = 1
cnt = 0
for length, num in counter:
    if cnt >= 2:
        break
    if num >= 4 and cnt == 0:
        print((length**2))
        exit()
    if num >= 2:
        ans *= length
        cnt += 1
if cnt == 2:
    print(ans)
else:
    print((0))

from collections import Counter

n = int(eval(input()))
A = list(map(int, input().split()))
# 長さと個数の辞書
length_num = Counter(A)
# 長い順からの長さのリスト
lengths = sorted(list(length_num.keys()), reverse=True)
ans = 0
sides = []
# 長い辺の順にループ
for l in lengths:
    if length_num[l] >= 4:
        ans = max(ans, l * l)
    if length_num[l] >= 2:
        sides.append(l)
    if len(sides) == 2:
        ans = max(ans, sides[0] * sides[1])
        break
print(ans)

-N = int(eval(input())) +n = int(eval(input())) -counter = sorted(list(Counter(A).items()), key=lambda x: x[0], reverse=True) -ans = 1 -cnt = 0 -for length, num in counter: -    if cnt >= 2: +# 長さと個数の辞書 +length_num = Counter(A) +# 長い順からの長さのリスト +lengths = sorted(list(length_num.keys()), reverse=True) +ans = 0 +sides = [] +# 長い辺の順にループ +for l in lengths: +    if length_num[l] >= 4: +        ans = max(ans, l * l) +    if length_num[l] >= 2: +        sides.append(l) +    if len(sides) == 2: +        ans = max(ans, sides[0] * sides[1]) -    if num >= 4 and cnt == 0: -        print((length**2)) -        exit() -    if num >= 2: -        ans *= length -        cnt += 1 -if cnt == 2: -    print(ans) -else: -    print((0)) +print(ans)