n = int(eval(input()))

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

d = {}

for i in range(n):

    if A[i] not in d:

        d[A[i]] = 1

    else:

        d[A[i]] += 1

#print(d)



L = []

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

    if v >= 2:

        L.append([k, v])

L.sort(reverse=True)

if len(L) == 0:

    print((0))

elif len(L) == 1:

    if L[0][1] < 4:

        print((0))

    else:

        print(((L[0][0])**2))

else:

    if L[0][1] >= 4:

        print(((L[0][0])**2))

    else:

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

n = int(eval(input()))

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

d = {}

for i in range(n):

    if A[i] not in d:

        d[A[i]] = 1

    else:

        d[A[i]] += 1

ans = 0

l = []

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

    if v >= 4:

        ans = max(ans, k**2)

        l.append(k)

    elif v >= 2:

        l.append(k)

    else:

        continue

if len(l) <= 1:

    print(ans)

else:

    l.sort(reverse=True)

    ans = max(ans, l[0]*l[1])

    print(ans)

n = int(eval(input()))
A = list(map(int, input().split()))
d = {}
for i in range(n):
    if A[i] not in d:
        d[A[i]] = 1
    else:
        d[A[i]] += 1
# print(d)
L = []
for k, v in list(d.items()):
    if v >= 2:
        L.append([k, v])
L.sort(reverse=True)
if len(L) == 0:
    print((0))
elif len(L) == 1:
    if L[0][1] < 4:
        print((0))
    else:
        print(((L[0][0]) ** 2))
else:
    if L[0][1] >= 4:
        print(((L[0][0]) ** 2))
    else:
        print((L[0][0] * L[1][0]))

n = int(eval(input()))
A = list(map(int, input().split()))
d = {}
for i in range(n):
    if A[i] not in d:
        d[A[i]] = 1
    else:
        d[A[i]] += 1
ans = 0
l = []
for k, v in list(d.items()):
    if v >= 4:
        ans = max(ans, k**2)
        l.append(k)
    elif v >= 2:
        l.append(k)
    else:
        continue
if len(l) <= 1:
    print(ans)
else:
    l.sort(reverse=True)
    ans = max(ans, l[0] * l[1])
    print(ans)

-# print(d) -L = [] +ans = 0 +l = [] -    if v >= 2: -        L.append([k, v]) -L.sort(reverse=True) -if len(L) == 0: -    print((0)) -elif len(L) == 1: -    if L[0][1] < 4: -        print((0)) +    if v >= 4: +        ans = max(ans, k**2) +        l.append(k) +    elif v >= 2: +        l.append(k) -        print(((L[0][0]) ** 2)) +        continue +if len(l) <= 1: +    print(ans) -    if L[0][1] >= 4: -        print(((L[0][0]) ** 2)) -    else: -        print((L[0][0] * L[1][0])) +    l.sort(reverse=True) +    ans = max(ans, l[0] * l[1]) +    print(ans)