N = int(eval(input()))

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



C = {}



count = 0

H = 0

W = 0



res1=res2=res3=0



for i in A:

    C[i] = 0



for i in A:

    C[i] += 1



for i in A:

    if C[i] >= 2:

        res1 = max(res1, i)



for i in A:

    if C[i] >= 2 and i != res1:

        res2 = max(res2, i)



for i in A:

    if C[i] >= 4:

        res3 = max(res3, i)





print((max(res1 * res2, res3 * res3)))
N = int(eval(input()))

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



A.sort()



wh = [0,0]



tmp = 0

for i in A:

    if i == tmp:

        wh.append(i)

        tmp = 0

    else:

        tmp = i



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

N = int(eval(input()))
A = list(map(int, input().split()))
C = {}
count = 0
H = 0
W = 0
res1 = res2 = res3 = 0
for i in A:
    C[i] = 0
for i in A:
    C[i] += 1
for i in A:
    if C[i] >= 2:
        res1 = max(res1, i)
for i in A:
    if C[i] >= 2 and i != res1:
        res2 = max(res2, i)
for i in A:
    if C[i] >= 4:
        res3 = max(res3, i)
print((max(res1 * res2, res3 * res3)))

N = int(eval(input()))
A = list(map(int, input().split()))
A.sort()
wh = [0, 0]
tmp = 0
for i in A:
    if i == tmp:
        wh.append(i)
        tmp = 0
    else:
        tmp = i
print((wh[-1] * wh[-2]))

-C = {} -count = 0 -H = 0 -W = 0 -res1 = res2 = res3 = 0 +A.sort() +wh = [0, 0] +tmp = 0 -    C[i] = 0 -for i in A: -    C[i] += 1 -for i in A: -    if C[i] >= 2: -        res1 = max(res1, i) -for i in A: -    if C[i] >= 2 and i != res1: -        res2 = max(res2, i) -for i in A: -    if C[i] >= 4: -        res3 = max(res3, i) -print((max(res1 * res2, res3 * res3))) +    if i == tmp: +        wh.append(i) +        tmp = 0 +    else: +        tmp = i +print((wh[-1] * wh[-2]))