import sys

def input(): return sys.stdin.readline().strip()



def resolve():

    n=int(eval(input()))

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

    from collections import Counter

    c=Counter(l)# ()にカウンターの対象のリストの変数名

    cl=list(c.items())

    cl.sort(key=lambda x:x[0],reverse=True)

    ans=[]

    for key,value in cl:

        if value>=4:

            if len(ans)==0:

                ans.append(key)

                ans.append(key)

                break

            elif len(ans)==1:

                ans.append(key)

                break

        elif value>=2:

            ans.append(key)

            if len(ans)==2:

                break

    if ans:

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

    else:

        print((0))

resolve()
import sys

def input(): return sys.stdin.readline().strip()



def resolve():

    n=int(eval(input()))

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

    from collections import Counter

    c=Counter(l)# ()にカウンターの対象のリストの変数名

    ans=[]

    for key,value in list(c.items()):

        if value>=4:

            ans.append(key)

            ans.append(key)

        elif value>=2:

            ans.append(key)

    ans.sort(reverse=True)

    if ans:

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

    else:

        print((0))

resolve()
import sys


def input():
    return sys.stdin.readline().strip()


def resolve():
    n = int(eval(input()))
    l = list(map(int, input().split()))
    from collections import Counter

    c = Counter(l)  # ()にカウンターの対象のリストの変数名
    cl = list(c.items())
    cl.sort(key=lambda x: x[0], reverse=True)
    ans = []
    for key, value in cl:
        if value >= 4:
            if len(ans) == 0:
                ans.append(key)
                ans.append(key)
                break
            elif len(ans) == 1:
                ans.append(key)
                break
        elif value >= 2:
            ans.append(key)
            if len(ans) == 2:
                break
    if ans:
        print((ans[0] * ans[1]))
    else:
        print((0))


resolve()

import sys


def input():
    return sys.stdin.readline().strip()


def resolve():
    n = int(eval(input()))
    l = list(map(int, input().split()))
    from collections import Counter

    c = Counter(l)  # ()にカウンターの対象のリストの変数名
    ans = []
    for key, value in list(c.items()):
        if value >= 4:
            ans.append(key)
            ans.append(key)
        elif value >= 2:
            ans.append(key)
    ans.sort(reverse=True)
    if ans:
        print((ans[0] * ans[1]))
    else:
        print((0))


resolve()

-    cl = list(c.items()) -    cl.sort(key=lambda x: x[0], reverse=True) -    for key, value in cl: +    for key, value in list(c.items()): -            if len(ans) == 0: -                ans.append(key) -                ans.append(key) -                break -            elif len(ans) == 1: -                ans.append(key) -                break +            ans.append(key) +            ans.append(key) -            if len(ans) == 2: -                break +    ans.sort(reverse=True)