import bisect, collections, copy, heapq, itertools, math, string, sys

input = lambda: sys.stdin.readline().rstrip() 

sys.setrecursionlimit(10**7)

INF = float('inf')

def I(): return int(eval(input()))

def F(): return float(eval(input()))

def SS(): return eval(input())

def LI(): return [int(x) for x in input().split()]

def LI_(): return [int(x)-1 for x in input().split()]

def LF(): return [float(x) for x in input().split()]

def LSS(): return input().split()



def resolve():

    N = I()

    A = LI()



    cnt = collections.Counter(A)

    edge = [(k, v) for k, v in list(cnt.items()) if v >= 2]

    edge.sort(reverse=True)



    if len(edge) >= 1 and edge[0][1] >= 4:

        ans = edge[0][0] ** 2

    elif len(edge) >= 2:

        ans = edge[0][0] * edge[1][0]

    else:

        ans = 0



    print(ans)



if __name__ == '__main__':

    resolve()

import bisect, collections, copy, heapq, itertools, math, string, sys

input = lambda: sys.stdin.readline().rstrip() 

sys.setrecursionlimit(10**7)

INF = float('inf')

def I(): return int(eval(input()))

def F(): return float(eval(input()))

def SS(): return eval(input())

def LI(): return [int(x) for x in input().split()]

def LI_(): return [int(x)-1 for x in input().split()]

def LF(): return [float(x) for x in input().split()]

def LSS(): return input().split()



def resolve():

    N = I()

    A = LI()



    cnt = collections.Counter(A)

    edge = [k for k, v in list(cnt.items()) if v >= 2]

    edge.sort(reverse=True)





    if len(edge) >= 1 and cnt[edge[0]] >= 4:

        ans = edge[0] ** 2

    elif len(edge) >= 2:

        ans = edge[0] * edge[1]

    else:

        ans = 0



    print(ans)



if __name__ == '__main__':

    resolve()

import bisect, collections, copy, heapq, itertools, math, string, sys

input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**7)
INF = float("inf")


def I():
    return int(eval(input()))


def F():
    return float(eval(input()))


def SS():
    return eval(input())


def LI():
    return [int(x) for x in input().split()]


def LI_():
    return [int(x) - 1 for x in input().split()]


def LF():
    return [float(x) for x in input().split()]


def LSS():
    return input().split()


def resolve():
    N = I()
    A = LI()
    cnt = collections.Counter(A)
    edge = [(k, v) for k, v in list(cnt.items()) if v >= 2]
    edge.sort(reverse=True)
    if len(edge) >= 1 and edge[0][1] >= 4:
        ans = edge[0][0] ** 2
    elif len(edge) >= 2:
        ans = edge[0][0] * edge[1][0]
    else:
        ans = 0
    print(ans)


if __name__ == "__main__":
    resolve()

import bisect, collections, copy, heapq, itertools, math, string, sys

input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**7)
INF = float("inf")


def I():
    return int(eval(input()))


def F():
    return float(eval(input()))


def SS():
    return eval(input())


def LI():
    return [int(x) for x in input().split()]


def LI_():
    return [int(x) - 1 for x in input().split()]


def LF():
    return [float(x) for x in input().split()]


def LSS():
    return input().split()


def resolve():
    N = I()
    A = LI()
    cnt = collections.Counter(A)
    edge = [k for k, v in list(cnt.items()) if v >= 2]
    edge.sort(reverse=True)
    if len(edge) >= 1 and cnt[edge[0]] >= 4:
        ans = edge[0] ** 2
    elif len(edge) >= 2:
        ans = edge[0] * edge[1]
    else:
        ans = 0
    print(ans)


if __name__ == "__main__":
    resolve()

-    edge = [(k, v) for k, v in list(cnt.items()) if v >= 2] +    edge = [k for k, v in list(cnt.items()) if v >= 2] -    if len(edge) >= 1 and edge[0][1] >= 4: -        ans = edge[0][0] ** 2 +    if len(edge) >= 1 and cnt[edge[0]] >= 4: +        ans = edge[0] ** 2 -        ans = edge[0][0] * edge[1][0] +        ans = edge[0] * edge[1]