n = int(eval(input()))

a = sorted(list(map(int,input().split())),reverse=True)

a += [0]

b = -1

ans = [0,0]

count = 0

for i in range(n+1):

    count += 1

    if b != a[i]:

        if count >= 4:

            if ans[0]:

                ans[1] = b

                break

            else:

                ans[0] = b

                ans[1] = b

                break

        elif count >= 2:

            if ans[0]:

                ans[1] = b

                break

            else:ans[0] = b

        b = a[i]

        count = 0

print((ans[0]*ans[1]))
from collections import Counter

n = int(eval(input()))

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

a = Counter(a)

ary = [0,0]

for i in a:

    if a[i] >= 4:

        ary.append(i)

        ary.append(i)

    elif a[i] >= 2:

        ary.append(i)

ary.sort()

print((ary.pop()*ary.pop()))
n = int(eval(input()))
a = sorted(list(map(int, input().split())), reverse=True)
a += [0]
b = -1
ans = [0, 0]
count = 0
for i in range(n + 1):
    count += 1
    if b != a[i]:
        if count >= 4:
            if ans[0]:
                ans[1] = b
                break
            else:
                ans[0] = b
                ans[1] = b
                break
        elif count >= 2:
            if ans[0]:
                ans[1] = b
                break
            else:
                ans[0] = b
        b = a[i]
        count = 0
print((ans[0] * ans[1]))

from collections import Counter

n = int(eval(input()))
a = list(map(int, input().split()))
a = Counter(a)
ary = [0, 0]
for i in a:
    if a[i] >= 4:
        ary.append(i)
        ary.append(i)
    elif a[i] >= 2:
        ary.append(i)
ary.sort()
print((ary.pop() * ary.pop()))

+from collections import Counter + -a = sorted(list(map(int, input().split())), reverse=True) -a += [0] -b = -1 -ans = [0, 0] -count = 0 -for i in range(n + 1): -    count += 1 -    if b != a[i]: -        if count >= 4: -            if ans[0]: -                ans[1] = b -                break -            else: -                ans[0] = b -                ans[1] = b -                break -        elif count >= 2: -            if ans[0]: -                ans[1] = b -                break -            else: -                ans[0] = b -        b = a[i] -        count = 0 -print((ans[0] * ans[1])) +a = list(map(int, input().split())) +a = Counter(a) +ary = [0, 0] +for i in a: +    if a[i] >= 4: +        ary.append(i) +        ary.append(i) +    elif a[i] >= 2: +        ary.append(i) +ary.sort() +print((ary.pop() * ary.pop()))