from collections import defaultdict

N = int(eval(input()))



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



edge_dic = defaultdict(int)

for n in range(N):

    edge_dic[al[n]] += 1

dic = sorted(list(edge_dic.items()), reverse=True)





yoko = 0

tate = 0

for v in dic:

    if yoko == 0:

        if v[1] >= 2:

            yoko = v[0]

            if v[1] >= 4:

                tate = v[0]

                break

    else:

        if v[1] >= 2:

            tate = v[0]

            break

print((yoko * tate))

from collections import Counter



N = int(eval(input()))

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



C_al = Counter(al)



al.sort(reverse=True)



tate = 0

yoko = 0



lst = list(C_al.keys())

lst.sort(reverse=True)



for edge in lst:

    if C_al[edge] >= 2:

        if tate == 0:

            tate = edge

            if C_al[edge] >= 4 and yoko == 0:

                yoko = edge

                print((tate * yoko))

                exit()

            else:

                pass

        else:

            yoko = edge

            print((tate * yoko))

            exit()

print((tate * yoko))

from collections import defaultdict

N = int(eval(input()))
al = list(map(int, input().split()))
edge_dic = defaultdict(int)
for n in range(N):
    edge_dic[al[n]] += 1
dic = sorted(list(edge_dic.items()), reverse=True)
yoko = 0
tate = 0
for v in dic:
    if yoko == 0:
        if v[1] >= 2:
            yoko = v[0]
            if v[1] >= 4:
                tate = v[0]
                break
    else:
        if v[1] >= 2:
            tate = v[0]
            break
print((yoko * tate))

from collections import Counter

N = int(eval(input()))
al = list(map(int, input().split()))
C_al = Counter(al)
al.sort(reverse=True)
tate = 0
yoko = 0
lst = list(C_al.keys())
lst.sort(reverse=True)
for edge in lst:
    if C_al[edge] >= 2:
        if tate == 0:
            tate = edge
            if C_al[edge] >= 4 and yoko == 0:
                yoko = edge
                print((tate * yoko))
                exit()
            else:
                pass
        else:
            yoko = edge
            print((tate * yoko))
            exit()
print((tate * yoko))

-from collections import defaultdict +from collections import Counter -edge_dic = defaultdict(int) -for n in range(N): -    edge_dic[al[n]] += 1 -dic = sorted(list(edge_dic.items()), reverse=True) +C_al = Counter(al) +al.sort(reverse=True) +tate = 0 -tate = 0 -for v in dic: -    if yoko == 0: -        if v[1] >= 2: -            yoko = v[0] -            if v[1] >= 4: -                tate = v[0] -                break -    else: -        if v[1] >= 2: -            tate = v[0] -            break -print((yoko * tate)) +lst = list(C_al.keys()) +lst.sort(reverse=True) +for edge in lst: +    if C_al[edge] >= 2: +        if tate == 0: +            tate = edge +            if C_al[edge] >= 4 and yoko == 0: +                yoko = edge +                print((tate * yoko)) +                exit() +            else: +                pass +        else: +            yoko = edge +            print((tate * yoko)) +            exit() +print((tate * yoko))