n = int(eval(input()))

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

bar = dict()

for i in range(n):

    if a[i] not in bar:

        bar[a[i]] = 0

    bar[a[i]] += 1

l_bar = list(bar.items())

l_bar.sort(reverse=True)

cnt = 0

hen1 = 0

hen2 = 0

for i in range(len(l_bar)):

    if l_bar[i][1] >= 4 and cnt == 0:

        print((l_bar[i][0]**2))

        exit()

    if l_bar[i][1] >= 2:

        if cnt == 0:

            cnt += 1

            hen1 = l_bar[i][0]

        elif cnt == 1:

            cnt += 1

            hen2 = l_bar[i][0]

    if cnt == 2:

        print((hen1*hen2))

        exit()

print((0))







import collections

n = int(eval(input()))

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

a = collections.Counter(a)

a = list(a.items())

a.sort(reverse=True)

e1 = 0

e2 = 0

for i in range(len(a)):

    if a[i][1] >= 4 and e1 == 0:

        e1 = e2 = a[i][0]

        break

    elif a[i][1] >= 2:

        if e1 == 0:

            e1 = a[i][0]

        else:

            e2 = a[i][0]

            break

print((e1*e2))





n = int(eval(input()))
a = list(map(int, input().split()))
bar = dict()
for i in range(n):
    if a[i] not in bar:
        bar[a[i]] = 0
    bar[a[i]] += 1
l_bar = list(bar.items())
l_bar.sort(reverse=True)
cnt = 0
hen1 = 0
hen2 = 0
for i in range(len(l_bar)):
    if l_bar[i][1] >= 4 and cnt == 0:
        print((l_bar[i][0] ** 2))
        exit()
    if l_bar[i][1] >= 2:
        if cnt == 0:
            cnt += 1
            hen1 = l_bar[i][0]
        elif cnt == 1:
            cnt += 1
            hen2 = l_bar[i][0]
    if cnt == 2:
        print((hen1 * hen2))
        exit()
print((0))

import collections

n = int(eval(input()))
a = list(map(int, input().split()))
a = collections.Counter(a)
a = list(a.items())
a.sort(reverse=True)
e1 = 0
e2 = 0
for i in range(len(a)):
    if a[i][1] >= 4 and e1 == 0:
        e1 = e2 = a[i][0]
        break
    elif a[i][1] >= 2:
        if e1 == 0:
            e1 = a[i][0]
        else:
            e2 = a[i][0]
            break
print((e1 * e2))

+import collections + -bar = dict() -for i in range(n): -    if a[i] not in bar: -        bar[a[i]] = 0 -    bar[a[i]] += 1 -l_bar = list(bar.items()) -l_bar.sort(reverse=True) -cnt = 0 -hen1 = 0 -hen2 = 0 -for i in range(len(l_bar)): -    if l_bar[i][1] >= 4 and cnt == 0: -        print((l_bar[i][0] ** 2)) -        exit() -    if l_bar[i][1] >= 2: -        if cnt == 0: -            cnt += 1 -            hen1 = l_bar[i][0] -        elif cnt == 1: -            cnt += 1 -            hen2 = l_bar[i][0] -    if cnt == 2: -        print((hen1 * hen2)) -        exit() -print((0)) +a = collections.Counter(a) +a = list(a.items()) +a.sort(reverse=True) +e1 = 0 +e2 = 0 +for i in range(len(a)): +    if a[i][1] >= 4 and e1 == 0: +        e1 = e2 = a[i][0] +        break +    elif a[i][1] >= 2: +        if e1 == 0: +            e1 = a[i][0] +        else: +            e2 = a[i][0] +            break +print((e1 * e2))