from collections import Counter

N = int(eval(input()))

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

c = Counter(a)

ans = 0

s = []

for e in c:

    if c[e] >= 2:

        s.append(e)

    if c[e] >= 4:

        ans = max(ans,e*e)

s = sorted(s)

if len(s) < 2:

    print((0))

else:

    print((max(ans,s[-1]*s[-2])))

from collections import Counter

N = int(eval(input()))

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

C = Counter(A)

T = []

F = []

for e in C:

    if C[e] >= 4:

        F.append(e)

    if C[e] >= 2:

        T.append(e)

ans = 0

for e in F:

    ans = max(ans,e**2)

T = sorted(T)

if len(T) >= 2:

    ans = max(ans,T[-1]*T[-2])

print(ans)

from collections import Counter

N = int(eval(input()))
a = list(map(int, input().split()))
c = Counter(a)
ans = 0
s = []
for e in c:
    if c[e] >= 2:
        s.append(e)
    if c[e] >= 4:
        ans = max(ans, e * e)
s = sorted(s)
if len(s) < 2:
    print((0))
else:
    print((max(ans, s[-1] * s[-2])))

from collections import Counter

N = int(eval(input()))
A = list(map(int, input().split()))
C = Counter(A)
T = []
F = []
for e in C:
    if C[e] >= 4:
        F.append(e)
    if C[e] >= 2:
        T.append(e)
ans = 0
for e in F:
    ans = max(ans, e**2)
T = sorted(T)
if len(T) >= 2:
    ans = max(ans, T[-1] * T[-2])
print(ans)

-a = list(map(int, input().split())) -c = Counter(a) +A = list(map(int, input().split())) +C = Counter(A) +T = [] +F = [] +for e in C: +    if C[e] >= 4: +        F.append(e) +    if C[e] >= 2: +        T.append(e) -s = [] -for e in c: -    if c[e] >= 2: -        s.append(e) -    if c[e] >= 4: -        ans = max(ans, e * e) -s = sorted(s) -if len(s) < 2: -    print((0)) -else: -    print((max(ans, s[-1] * s[-2]))) +for e in F: +    ans = max(ans, e**2) +T = sorted(T) +if len(T) >= 2: +    ans = max(ans, T[-1] * T[-2]) +print(ans)