# encoding:utf-8

import copy

import random

import bisect #bisect_left　これで二部探索の大小検索が行える

import math





N = int(eval(input()))

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



A.sort()

len_dic = {}

for a in A:

    if a in list(len_dic.keys()):

        len_dic[a] += 1



    else:

        len_dic[a] = 1



ans = [0,0]

for k, v in sorted(list(len_dic.items()),key=lambda x:-x[0]):

    if v >= 4 and ans[0] == 0:

        ans = [k,k]

    elif v >= 2:

        if ans[0]==0:

            ans[0] = k

        elif ans[1] == 0:

            ans[1] = k



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

#!/usr/bin/env python3

# encoding:utf-8

import copy

import random

import bisect #bisect_left　これで二部探索の大小検索が行える

import fractions #最小公倍数などはこっち

import math

import sys

import collections

from decimal import Decimal # 10進数で考慮できる



mod = 10**9+7

sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000



d = collections.deque()

def LI(): return list(map(int, sys.stdin.readline().split()))



N = int(eval(input()))

A = LI()



A_collection = collections.Counter(A)

bars = []

for key in list(A_collection.keys()):

    if A_collection[key] > 1:

        bars.append(key)



ans = 0

bars.sort(reverse = 1)

if len(bars) > 1:

    ans = bars[0] * bars[1]

    if A_collection[bars[0]] > 3:

        ans = bars[0] ** 2

print(ans)

# encoding:utf-8
import copy
import random
import bisect  # bisect_left　これで二部探索の大小検索が行える
import math

N = int(eval(input()))
A = [int(i) for i in input().split()]
A.sort()
len_dic = {}
for a in A:
    if a in list(len_dic.keys()):
        len_dic[a] += 1
    else:
        len_dic[a] = 1
ans = [0, 0]
for k, v in sorted(list(len_dic.items()), key=lambda x: -x[0]):
    if v >= 4 and ans[0] == 0:
        ans = [k, k]
    elif v >= 2:
        if ans[0] == 0:
            ans[0] = k
        elif ans[1] == 0:
            ans[1] = k
print((ans[0] * ans[1]))

#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect  # bisect_left　これで二部探索の大小検索が行える
import fractions  # 最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal  # 10進数で考慮できる

mod = 10**9 + 7
sys.setrecursionlimit(mod)  # 再帰回数上限はでdefault1000
d = collections.deque()


def LI():
    return list(map(int, sys.stdin.readline().split()))


N = int(eval(input()))
A = LI()
A_collection = collections.Counter(A)
bars = []
for key in list(A_collection.keys()):
    if A_collection[key] > 1:
        bars.append(key)
ans = 0
bars.sort(reverse=1)
if len(bars) > 1:
    ans = bars[0] * bars[1]
    if A_collection[bars[0]] > 3:
        ans = bars[0] ** 2
print(ans)

+#!/usr/bin/env python3 +import fractions  # 最小公倍数などはこっち +import sys +import collections +from decimal import Decimal  # 10進数で考慮できる + +mod = 10**9 + 7 +sys.setrecursionlimit(mod)  # 再帰回数上限はでdefault1000 +d = collections.deque() + + +def LI(): +    return list(map(int, sys.stdin.readline().split())) + -A = [int(i) for i in input().split()] -A.sort() -len_dic = {} -for a in A: -    if a in list(len_dic.keys()): -        len_dic[a] += 1 -    else: -        len_dic[a] = 1 -ans = [0, 0] -for k, v in sorted(list(len_dic.items()), key=lambda x: -x[0]): -    if v >= 4 and ans[0] == 0: -        ans = [k, k] -    elif v >= 2: -        if ans[0] == 0: -            ans[0] = k -        elif ans[1] == 0: -            ans[1] = k -print((ans[0] * ans[1])) +A = LI() +A_collection = collections.Counter(A) +bars = [] +for key in list(A_collection.keys()): +    if A_collection[key] > 1: +        bars.append(key) +ans = 0 +bars.sort(reverse=1) +if len(bars) > 1: +    ans = bars[0] * bars[1] +    if A_collection[bars[0]] > 3: +        ans = bars[0] ** 2 +print(ans)