import sys

stdin = sys.stdin



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

def li_(): return [int(x)-1 for x in stdin.readline().split()]

def lf(): return list(map(float, stdin.readline().split()))

def ls(): return stdin.readline().split()

def ns(): return stdin.readline().rstrip()

def lc(): return list(ns())

def ni(): return int(stdin.readline())

def nf(): return float(stdin.readline())



from collections import Counter



n = ni()

a = list(li())



cnt = Counter(a)



lst = []

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

    lst.append((k,v))



lst.sort(reverse=True)



first = 0

second = 0



for k,v in lst:

    if v >= 4 and first == 0:

        first = k

        second = k

        break

    

    elif v >= 4:

        second = k

        break

        

    elif v >= 2 and first != 0:

        second = k

        break

    

    elif v >= 2:

        first = k

        

print((first*second))
import sys

stdin = sys.stdin

 

sys.setrecursionlimit(10**5) 

 

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

def li_(): return [int(x)-1 for x in stdin.readline().split()]

def lf(): return list(map(float, stdin.readline().split()))

def ls(): return stdin.readline().split()

def ns(): return stdin.readline().rstrip()

def lc(): return list(ns())

def ni(): return int(stdin.readline())

def nf(): return float(stdin.readline())



from collections import Counter



n = ni()

a = list(li())



cnt = Counter(a)



first = 0

second = 0



keys = list(cnt.keys())

keys.sort(reverse=True)



for k in keys:

    if first != 0 and second != 0:

        break

    

    if first == 0 and second == 0 and cnt[k] >= 4:

        first = k

        second = k

        

    elif first != 0 and cnt[k] >= 2:

        second = k

        

    elif cnt[k] >= 2:

        first = k

        

print((first * second))
import sys

stdin = sys.stdin


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


def li_():
    return [int(x) - 1 for x in stdin.readline().split()]


def lf():
    return list(map(float, stdin.readline().split()))


def ls():
    return stdin.readline().split()


def ns():
    return stdin.readline().rstrip()


def lc():
    return list(ns())


def ni():
    return int(stdin.readline())


def nf():
    return float(stdin.readline())


from collections import Counter

n = ni()
a = list(li())
cnt = Counter(a)
lst = []
for k, v in list(cnt.items()):
    lst.append((k, v))
lst.sort(reverse=True)
first = 0
second = 0
for k, v in lst:
    if v >= 4 and first == 0:
        first = k
        second = k
        break
    elif v >= 4:
        second = k
        break
    elif v >= 2 and first != 0:
        second = k
        break
    elif v >= 2:
        first = k
print((first * second))

import sys

stdin = sys.stdin
sys.setrecursionlimit(10**5)


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


def li_():
    return [int(x) - 1 for x in stdin.readline().split()]


def lf():
    return list(map(float, stdin.readline().split()))


def ls():
    return stdin.readline().split()


def ns():
    return stdin.readline().rstrip()


def lc():
    return list(ns())


def ni():
    return int(stdin.readline())


def nf():
    return float(stdin.readline())


from collections import Counter

n = ni()
a = list(li())
cnt = Counter(a)
first = 0
second = 0
keys = list(cnt.keys())
keys.sort(reverse=True)
for k in keys:
    if first != 0 and second != 0:
        break
    if first == 0 and second == 0 and cnt[k] >= 4:
        first = k
        second = k
    elif first != 0 and cnt[k] >= 2:
        second = k
    elif cnt[k] >= 2:
        first = k
print((first * second))

+sys.setrecursionlimit(10**5) -lst = [] -for k, v in list(cnt.items()): -    lst.append((k, v)) -lst.sort(reverse=True) -for k, v in lst: -    if v >= 4 and first == 0: +keys = list(cnt.keys()) +keys.sort(reverse=True) +for k in keys: +    if first != 0 and second != 0: +        break +    if first == 0 and second == 0 and cnt[k] >= 4: -        break -    elif v >= 4: +    elif first != 0 and cnt[k] >= 2: -        break -    elif v >= 2 and first != 0: -        second = k -        break -    elif v >= 2: +    elif cnt[k] >= 2: