from collections import Counter

N = int(eval(input()))

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

c = Counter()

for a in A:

    c[a] += 1

candidate = []

for k, v in c.most_common():

    if v >= 4:

        candidate.append(k)

        candidate.append(k)

    elif v >= 2:

        candidate.append(k)

candidate.sort()



if len(candidate) < 2:

    print((0))

else:

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

N = int(eval(input()))

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

A.sort(reverse=True)



res = A[0]

cnt = 1

use = []

for i in range(1, N):

    if A[i] == res:

        cnt += 1

    else:

        cnt = 1

        res = A[i]



    if cnt >= 2:

        use.append(A[i])

        cnt -= 2



    if len(use) >= 2:

        break



if len(use) >= 2:

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

else:

    print((0))

from collections import Counter

N = int(eval(input()))
A = list(map(int, input().split()))
c = Counter()
for a in A:
    c[a] += 1
candidate = []
for k, v in c.most_common():
    if v >= 4:
        candidate.append(k)
        candidate.append(k)
    elif v >= 2:
        candidate.append(k)
candidate.sort()
if len(candidate) < 2:
    print((0))
else:
    print((candidate[-1] * candidate[-2]))

N = int(eval(input()))
A = list(map(int, input().split()))
A.sort(reverse=True)
res = A[0]
cnt = 1
use = []
for i in range(1, N):
    if A[i] == res:
        cnt += 1
    else:
        cnt = 1
        res = A[i]
    if cnt >= 2:
        use.append(A[i])
        cnt -= 2
    if len(use) >= 2:
        break
if len(use) >= 2:
    print((use[0] * use[1]))
else:
    print((0))

-from collections import Counter - -c = Counter() -for a in A: -    c[a] += 1 -candidate = [] -for k, v in c.most_common(): -    if v >= 4: -        candidate.append(k) -        candidate.append(k) -    elif v >= 2: -        candidate.append(k) -candidate.sort() -if len(candidate) < 2: +A.sort(reverse=True) +res = A[0] +cnt = 1 +use = [] +for i in range(1, N): +    if A[i] == res: +        cnt += 1 +    else: +        cnt = 1 +        res = A[i] +    if cnt >= 2: +        use.append(A[i]) +        cnt -= 2 +    if len(use) >= 2: +        break +if len(use) >= 2: +    print((use[0] * use[1])) +else: -else: -    print((candidate[-1] * candidate[-2]))