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))
def main():

    N = int(eval(input()))

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

    

    A.sort(reverse=True)

    lines = []

    prev = ''

    for ai in A:

        if ai == prev:

            lines.append(ai)

            prev = ''

        else:

            prev = ai



    if len(lines) >= 2:

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

    else:

        print((0))

  



if __name__ == "__main__":

    main()
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))

def main():
    N = int(eval(input()))
    A = list(map(int, input().split()))
    A.sort(reverse=True)
    lines = []
    prev = ""
    for ai in A:
        if ai == prev:
            lines.append(ai)
            prev = ""
        else:
            prev = ai
    if len(lines) >= 2:
        print((lines[0] * lines[1]))
    else:
        print((0))


if __name__ == "__main__":
    main()

-from collections import Counter +def main(): +    N = int(eval(input())) +    A = list(map(int, input().split())) +    A.sort(reverse=True) +    lines = [] +    prev = "" +    for ai in A: +        if ai == prev: +            lines.append(ai) +            prev = "" +        else: +            prev = ai +    if len(lines) >= 2: +        print((lines[0] * lines[1])) +    else: +        print((0)) -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)) + +if __name__ == "__main__": +    main()