import collections



n=int(eval(input()))



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

        

X=collections.Counter(A)



ans=1

cnt_1=0

cnt_2=0



for k,v in sorted(list(X.items()),key=lambda x:x[0],reverse=True):

    if v>=2:

        cnt_1+=1

        ans*=k

        if cnt_1==2:

            break

        if v>=4:

            ans*=k

            break

    else:

        cnt_2+=1

        if cnt_2==n or cnt_2==n-2 or cnt_2==n-3:

            ans=0

            break

print(ans)


n=int(eval(input()))



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

        

A.sort(reverse=True)



X=[]



t=-1



for i in A:

    if t==i:

        t=-1

        X.append(i)

        if len(X)>1:

            break

    else:

        t=i

        

if len(X)>1:

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

else:

    print((0))
import collections

n = int(eval(input()))
A = list(map(int, input().split()))
X = collections.Counter(A)
ans = 1
cnt_1 = 0
cnt_2 = 0
for k, v in sorted(list(X.items()), key=lambda x: x[0], reverse=True):
    if v >= 2:
        cnt_1 += 1
        ans *= k
        if cnt_1 == 2:
            break
        if v >= 4:
            ans *= k
            break
    else:
        cnt_2 += 1
        if cnt_2 == n or cnt_2 == n - 2 or cnt_2 == n - 3:
            ans = 0
            break
print(ans)

n = int(eval(input()))
A = list(map(int, input().split()))
A.sort(reverse=True)
X = []
t = -1
for i in A:
    if t == i:
        t = -1
        X.append(i)
        if len(X) > 1:
            break
    else:
        t = i
if len(X) > 1:
    print((X[0] * X[1]))
else:
    print((0))

-import collections - -X = collections.Counter(A) -ans = 1 -cnt_1 = 0 -cnt_2 = 0 -for k, v in sorted(list(X.items()), key=lambda x: x[0], reverse=True): -    if v >= 2: -        cnt_1 += 1 -        ans *= k -        if cnt_1 == 2: -            break -        if v >= 4: -            ans *= k +A.sort(reverse=True) +X = [] +t = -1 +for i in A: +    if t == i: +        t = -1 +        X.append(i) +        if len(X) > 1: -        cnt_2 += 1 -        if cnt_2 == n or cnt_2 == n - 2 or cnt_2 == n - 3: -            ans = 0 -            break -print(ans) +        t = i +if len(X) > 1: +    print((X[0] * X[1])) +else: +    print((0))