from collections import Counter



N = int(eval(input()))

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



c = Counter()



for ai in A:

    c[ai] += 1



more_than_2 = []

for k, v in list(c.items()):

    if v >= 4:

        more_than_2.append(k)

    if v >= 2:

        more_than_2.append(k)



if len(more_than_2) < 2:

    print((0))

else:

    more_than_2.sort(reverse=True)

    ans = more_than_2[0] * more_than_2[1]

    print(ans)



from collections import Counter



N = int(eval(input()))

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



A.sort(reverse=True)

# print(A)

lines = []



cnt = 1

before = 'XXX'

for ai in A + ['YYY']:

    if ai == before:

        cnt += 1

    else:

        if cnt >= 4:

            lines.append(before)

            lines.append(before)

        elif cnt >=2:

            lines.append(before)



        if len(lines) >= 2:

            break

        

        cnt = 1

        before = ai





if len(lines) >= 2:

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

else:

    print((0))
from collections import Counter

N = int(eval(input()))
A = list(map(int, input().split()))
c = Counter()
for ai in A:
    c[ai] += 1
more_than_2 = []
for k, v in list(c.items()):
    if v >= 4:
        more_than_2.append(k)
    if v >= 2:
        more_than_2.append(k)
if len(more_than_2) < 2:
    print((0))
else:
    more_than_2.sort(reverse=True)
    ans = more_than_2[0] * more_than_2[1]
    print(ans)

from collections import Counter

N = int(eval(input()))
A = list(map(int, input().split()))
A.sort(reverse=True)
# print(A)
lines = []
cnt = 1
before = "XXX"
for ai in A + ["YYY"]:
    if ai == before:
        cnt += 1
    else:
        if cnt >= 4:
            lines.append(before)
            lines.append(before)
        elif cnt >= 2:
            lines.append(before)
        if len(lines) >= 2:
            break
        cnt = 1
        before = ai
if len(lines) >= 2:
    print((lines[0] * lines[1]))
else:
    print((0))

-c = Counter() -for ai in A: -    c[ai] += 1 -more_than_2 = [] -for k, v in list(c.items()): -    if v >= 4: -        more_than_2.append(k) -    if v >= 2: -        more_than_2.append(k) -if len(more_than_2) < 2: +A.sort(reverse=True) +# print(A) +lines = [] +cnt = 1 +before = "XXX" +for ai in A + ["YYY"]: +    if ai == before: +        cnt += 1 +    else: +        if cnt >= 4: +            lines.append(before) +            lines.append(before) +        elif cnt >= 2: +            lines.append(before) +        if len(lines) >= 2: +            break +        cnt = 1 +        before = ai +if len(lines) >= 2: +    print((lines[0] * lines[1])) +else: -else: -    more_than_2.sort(reverse=True) -    ans = more_than_2[0] * more_than_2[1] -    print(ans)