from collections import Counter



eval(input())

d = Counter(list(map(int, input().split())))

d = dict(sorted(list(d.items()), reverse=True))

ans = []

for i, j in list(d.items()):

    if j >= 4:

        ans.append(i)

    if j >= 2:

        ans.append(i)

if len(ans) >= 2:

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

else:

    print((0))
from collections import Counter



eval(input())

ans = []

for i, j in list(Counter(list(map(int, input().split()))).items()):

    if j >= 4:

        ans.append(i)

    if j >= 2:

        ans.append(i)

if len(ans) >= 2:

    ans.sort()

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

else:

    print((0))

from collections import Counter

eval(input())
d = Counter(list(map(int, input().split())))
d = dict(sorted(list(d.items()), reverse=True))
ans = []
for i, j in list(d.items()):
    if j >= 4:
        ans.append(i)
    if j >= 2:
        ans.append(i)
if len(ans) >= 2:
    print((ans[0] * ans[1]))
else:
    print((0))

from collections import Counter

eval(input())
ans = []
for i, j in list(Counter(list(map(int, input().split()))).items()):
    if j >= 4:
        ans.append(i)
    if j >= 2:
        ans.append(i)
if len(ans) >= 2:
    ans.sort()
    print((ans[-1] * ans[-2]))
else:
    print((0))

-d = Counter(list(map(int, input().split()))) -d = dict(sorted(list(d.items()), reverse=True)) -for i, j in list(d.items()): +for i, j in list(Counter(list(map(int, input().split()))).items()): -    print((ans[0] * ans[1])) +    ans.sort() +    print((ans[-1] * ans[-2]))