def inpl():

    return input().split()



n = int(eval(input()))

a = list(map(int, inpl()))

a = sorted(a, reverse=True)



ans = 1

cnt = 0

bf = a[0]

i = 1

while (i < n) and (cnt < 2):

    a_i = a[i]

    if bf == a_i:

        ans *= a_i

        bf = -1

        cnt += 1

    else:

        bf = a_i

    i += 1

print((ans if cnt == 2 else 0))
n = int(eval(input()))

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

a = sorted(a, reverse=True)



anss = []

t = -1

for i in range(n):

    if t == a[i]:

        anss.append(t)

        t = -1

        if len(anss) >= 2:

            break

    else:

        t = a[i]



if len(anss) >= 2:

    ans = 1

    for x in anss:

        ans *= x

else:

    ans = 0

print(ans)
def inpl():
    return input().split()


n = int(eval(input()))
a = list(map(int, inpl()))
a = sorted(a, reverse=True)
ans = 1
cnt = 0
bf = a[0]
i = 1
while (i < n) and (cnt < 2):
    a_i = a[i]
    if bf == a_i:
        ans *= a_i
        bf = -1
        cnt += 1
    else:
        bf = a_i
    i += 1
print((ans if cnt == 2 else 0))

n = int(eval(input()))
a = list(map(int, input().split()))
a = sorted(a, reverse=True)
anss = []
t = -1
for i in range(n):
    if t == a[i]:
        anss.append(t)
        t = -1
        if len(anss) >= 2:
            break
    else:
        t = a[i]
if len(anss) >= 2:
    ans = 1
    for x in anss:
        ans *= x
else:
    ans = 0
print(ans)

-def inpl(): -    return input().split() - - -a = list(map(int, inpl())) +a = list(map(int, input().split())) -ans = 1 -cnt = 0 -bf = a[0] -i = 1 -while (i < n) and (cnt < 2): -    a_i = a[i] -    if bf == a_i: -        ans *= a_i -        bf = -1 -        cnt += 1 +anss = [] +t = -1 +for i in range(n): +    if t == a[i]: +        anss.append(t) +        t = -1 +        if len(anss) >= 2: +            break -        bf = a_i -    i += 1 -print((ans if cnt == 2 else 0)) +        t = a[i] +if len(anss) >= 2: +    ans = 1 +    for x in anss: +        ans *= x +else: +    ans = 0 +print(ans)