def solve():

    N = int(eval(input()))

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

    A.sort()



    Adict = dict()

    for i, a in enumerate(A):

        if a in Adict: Adict[a] += 1

        else: Adict[a] = 1



    rect = 0

    ri = -1

    for i in reversed(list(range(N))):

        if Adict[A[i]] >= 4:

            rect = A[i] ** 2

            break

        if Adict[A[i]] >= 2:

            rect = A[i]

            ri = i

            break

    if ri > -1:

        for i in reversed(list(range(ri))):

            if Adict[A[i]] >= 2 and A[i] != rect:

                rect *= A[i]

                break

    print(rect)



if __name__ == "__main__":

    solve()

import sys

from heapq import heapify, heappop, heappush



def solve():

    input = sys.stdin.readline

    N = int(eval(input()))

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

    Anum = dict()

    for a in A:

        if a in Anum: Anum[a] += 1

        else: Anum[a] = 1

    q = [0, 0]

    for key in Anum:

        if Anum[key] >= 2: q.append(-key)  

        if Anum[key] >= 4: q.append(-key)

    heapify(q)

    x = heappop(q)

    y = heappop(q)

    print((x * y))





    return 0



if __name__ == "__main__":

    solve()
def solve():
    N = int(eval(input()))
    A = [int(a) for a in input().split()]
    A.sort()
    Adict = dict()
    for i, a in enumerate(A):
        if a in Adict:
            Adict[a] += 1
        else:
            Adict[a] = 1
    rect = 0
    ri = -1
    for i in reversed(list(range(N))):
        if Adict[A[i]] >= 4:
            rect = A[i] ** 2
            break
        if Adict[A[i]] >= 2:
            rect = A[i]
            ri = i
            break
    if ri > -1:
        for i in reversed(list(range(ri))):
            if Adict[A[i]] >= 2 and A[i] != rect:
                rect *= A[i]
                break
    print(rect)


if __name__ == "__main__":
    solve()

import sys
from heapq import heapify, heappop, heappush


def solve():
    input = sys.stdin.readline
    N = int(eval(input()))
    A = [int(a) for a in input().split()]
    Anum = dict()
    for a in A:
        if a in Anum:
            Anum[a] += 1
        else:
            Anum[a] = 1
    q = [0, 0]
    for key in Anum:
        if Anum[key] >= 2:
            q.append(-key)
        if Anum[key] >= 4:
            q.append(-key)
    heapify(q)
    x = heappop(q)
    y = heappop(q)
    print((x * y))
    return 0


if __name__ == "__main__":
    solve()

+import sys +from heapq import heapify, heappop, heappush + + +    input = sys.stdin.readline -    A.sort() -    Adict = dict() -    for i, a in enumerate(A): -        if a in Adict: -            Adict[a] += 1 +    Anum = dict() +    for a in A: +        if a in Anum: +            Anum[a] += 1 -            Adict[a] = 1 -    rect = 0 -    ri = -1 -    for i in reversed(list(range(N))): -        if Adict[A[i]] >= 4: -            rect = A[i] ** 2 -            break -        if Adict[A[i]] >= 2: -            rect = A[i] -            ri = i -            break -    if ri > -1: -        for i in reversed(list(range(ri))): -            if Adict[A[i]] >= 2 and A[i] != rect: -                rect *= A[i] -                break -    print(rect) +            Anum[a] = 1 +    q = [0, 0] +    for key in Anum: +        if Anum[key] >= 2: +            q.append(-key) +        if Anum[key] >= 4: +            q.append(-key) +    heapify(q) +    x = heappop(q) +    y = heappop(q) +    print((x * y)) +    return 0