# import bisect

from collections import Counter, deque

# from copy import copy, deepcopy

# from fractions import gcd

# from functools import reduce

# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product

# import math

# import numpy as np

# from operator import xor

import sys

sys.setrecursionlimit(10 ** 5 + 10)

# input = sys.stdin.readline



def resolve():



    N=int(eval(input()))

    A=sorted(list(map(int,input().split())),reverse=True)

    temp=-1

    maxans=0

    AA=Counter(A)

    for (i,j) in list(AA.items()):

        if j>=4:

            maxans=max(i**2,maxans)

        if j>=2:

            if temp>=0:

                maxans=max(maxans,temp*i)

            temp=max(i,temp)

    print(maxans)









resolve()
from collections import Counter, deque, OrderedDict

# from copy import copy, deepcopy

# from functools import reduce

# from heapq import heapify, heappop, heappush

# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product

# import math

# import numpy as np  # Pythonのみ！

# from operator import xor

# import re

# from scipy.sparse.csgraph import connected_components  # Pythonのみ！

# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/

# from scipy.sparse import csr_matrix

# import statistics # Pythonのみ

# import string

import sys

sys.setrecursionlimit(10 ** 5 + 10)

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





def resolve():

    N = int(eval(input()))

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

    A = Counter(A)



    ans=[0,0]

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

        if v>=2:

            ans.append(k)

        if v>=4:

            ans.append(k)

    ans.sort()

    print((ans[-1]*ans[-2]))





resolve()
# import bisect
from collections import Counter, deque

# from copy import copy, deepcopy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np
# from operator import xor
import sys

sys.setrecursionlimit(10**5 + 10)
# input = sys.stdin.readline
def resolve():
    N = int(eval(input()))
    A = sorted(list(map(int, input().split())), reverse=True)
    temp = -1
    maxans = 0
    AA = Counter(A)
    for (i, j) in list(AA.items()):
        if j >= 4:
            maxans = max(i**2, maxans)
        if j >= 2:
            if temp >= 0:
                maxans = max(maxans, temp * i)
            temp = max(i, temp)
    print(maxans)


resolve()

from collections import Counter, deque, OrderedDict

# from copy import copy, deepcopy
# from functools import reduce
# from heapq import heapify, heappop, heappush
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import statistics # Pythonのみ
# import string
import sys

sys.setrecursionlimit(10**5 + 10)


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


def resolve():
    N = int(eval(input()))
    A = list(map(int, input().split()))
    A = Counter(A)
    ans = [0, 0]
    for k, v in list(A.items()):
        if v >= 2:
            ans.append(k)
        if v >= 4:
            ans.append(k)
    ans.sort()
    print((ans[-1] * ans[-2]))


resolve()

-# import bisect -from collections import Counter, deque +from collections import Counter, deque, OrderedDict -# from fractions import gcd +# from heapq import heapify, heappop, heappush -# import numpy as np +# import numpy as np  # Pythonのみ！ +# import re +# from scipy.sparse.csgraph import connected_components  # Pythonのみ！ +# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/ +# from scipy.sparse import csr_matrix +# import statistics # Pythonのみ +# import string -# input = sys.stdin.readline + + +def input(): +    return sys.stdin.readline().strip() + + -    A = sorted(list(map(int, input().split())), reverse=True) -    temp = -1 -    maxans = 0 -    AA = Counter(A) -    for (i, j) in list(AA.items()): -        if j >= 4: -            maxans = max(i**2, maxans) -        if j >= 2: -            if temp >= 0: -                maxans = max(maxans, temp * i) -            temp = max(i, temp) -    print(maxans) +    A = list(map(int, input().split())) +    A = Counter(A) +    ans = [0, 0] +    for k, v in list(A.items()): +        if v >= 2: +            ans.append(k) +        if v >= 4: +            ans.append(k) +    ans.sort() +    print((ans[-1] * ans[-2]))