CodeEff/ECCO huggingface dataset:
# Original solution
from collections import Counter
n = int(eval(input()))
a = list(map(int, input().split()))

count = Counter(a)
ans = [0]*2
t = 0
for i in sorted(list(count.items()), reverse=True):
  if i[1] >= 4:
    if t == 0:
      ans[0],ans[1] = i[0],i[0]
      t = 2
    elif t == 1:
      ans[t] = i[0]
      t += 1
  elif i[1] >= 2:
    ans[t] = i[0]
    t += 1
  if t == 2: break
print((ans[0]*ans[1]))

# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split()))

d = {}
for i in a:
  if i in d: d[i] += 1
  else: d[i] = 1

t = 0
ans = []
for k,v in sorted(list(d.items()), key=lambda x: x[0], reverse=True):
  if v >= 4 and t == 0:
    print((k*k))
    exit()
  elif v >= 2:
    ans.append(k)
    t += 1
  if t == 2:
    print((ans[0]*ans[1]))
    exit()
print((0))
# Original solution
N = int(eval(input()))
A = [int(x) for x in input().split()]

A.sort()
A.reverse()

for i in range(N - 1):
    if A[i] == A[i + 1]:
        A[i + 1] = 0
    else:
        A[i] = 0

A.sort()
A.reverse()
print((A[0] * A[1]))


# Optimized solution
N = int(eval(input()))
A = [int(x) for x in input().split()]

A.sort()

for i in range(N - 1):
    if A[i] == A[i + 1]:
        A[i + 1] = 0
    else:
        A[i] = 0

A[N - 1] = 0

A.sort()
A.reverse()
print((A[0] * A[1]))
# Original solution
from collections import Counter
import sys
N = int(eval(input()))
A = [int(_) for _ in input().split()]

key_val_lis = []
for key, value in list(Counter(A).items()):
    if value >= 2:
        key_val_lis.append((key, value))

ans_lis = sorted(key_val_lis, key=lambda x: -x[0])

if len(ans_lis) <= 1 or ans_lis[0][1] is None:
        print((0))
        sys.exit()

area_1 = ans_lis[0][0] * ans_lis[1][0]
area_2 = 0
if ans_lis[0][1] >= 4:
    area_2 = ans_lis[0][0] ** 2
print((max(area_1, area_2)))


# Optimized solution
from collections import Counter
import sys
N = int(eval(input()))
A = [int(_) for _ in input().split()]

key_val_lis = []
for key, value in list(Counter(A).items()):
    if value >= 2:
        key_val_lis.append((key, value))

ans_lis = sorted(key_val_lis, key=lambda x: -x[0])
#print(ans_lis)
if not ans_lis:
    print((0))
    sys.exit()

if len(ans_lis) == 1 and ans_lis[0][1] < 4:
    print((0))
elif len(ans_lis) == 1 and ans_lis[0][1] >= 4:
    print((ans_lis[0][0] ** 2))
elif len(ans_lis) >= 2:
    area_1 = ans_lis[0][0] * ans_lis[1][0]
    area_2 = 0
    if ans_lis[0][1] >= 4:
        area_2 = ans_lis[0][0] ** 2
    print((max(area_1, area_2)))
# Original solution
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)

# Optimized solution

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))
# Original solution
N = int(eval(input()))
A = sorted(list(map(int, input().split())))
l1, l2 = 0, 0
while len(A) > 1:
    if A[-1] == A[-2] and l1 == 0:
        l1 = A[-1]
        A = A[:-2]
    elif A[-1] == A[-2] and l2 == 0:
        l2 = A[-1]
        break
    else:
        A = A[:-1]
print((l1 * l2))


# Optimized solution
N = int(eval(input()))
A = sorted(list(map(int, input().split())))[::-1]
l1, l2 = 0, 0
flag = True
for i in range(N-1):
    if A[i] > A[i+1]:
        flag = True
        pass
    elif l1 == 0:
        l1 = A[i]
        flag = False
    elif l2 == 0 and flag:
        l2 = A[i]
        break
    else:
        flag = True

print((l1 * l2))
# Original solution
eval(input())
a = list(map(int,input().split()))
sa = list(set(a))
b = [ i for i in sa if a.count(i)>=2 ]
c = [ i for i in sa if a.count(i)>=4 ]
b=b+c
b.sort(reverse=True)

if len(b)>=2:
    print((b[0]*b[1]))
else:
    print((0))


# Optimized solution
n = int(eval(input()))
a = list(map(int,input().split()))
a.sort(reverse=True)
bn = 0
ans = 0
count = 0
i = 0

while(i<n):
    if bn==a[i]:
        if count == 0:
            ans = a[i]
            if i+1<n:
                bn = a[i+1]
            i += 1
            count +=1
        else:
            ans *= a[i]
            count +=1
            break
    else:
        bn = a[i]
    i +=1

if count>=2:
    print(ans)
else:
    print((0))
# Original solution
from sys import stdin

n, *a = list(map(int, stdin.read().split()))
lengths = sorted(set(a), reverse=1)     
a.sort()

long_side, short_side = 0, 0
for l in lengths:
    c = a.count(l)
    if c != 1:
        if not long_side:
            if c >= 4:
                print((l ** 2))
                exit()
            else:
                long_side = l
        else:
            short_side = l
            break

print((long_side * short_side))

# Optimized solution
from sys import stdin

n, *a = list(map(int, stdin.read().split()))    
a.sort(reverse=1)

l_count = {}
for l in a:
    l_count.update({l: l_count.get(l, 0) + 1})
  
long_side, short_side = 0, 0
for l, c in sorted(list(l_count.items()), reverse=1):
    if c != 1:
        if not long_side:
            if c >= 4:
                print((l ** 2))
                exit()
            else:
                long_side = l
        else:
            short_side = l
            break

print((long_side * short_side))
# Original solution
from sys import stdin

n, *a = list(map(int, stdin.read().split()))    
a.sort(reverse=1)

l_count = {}
for l in a:
    l_count.update({l: l_count.get(l, 0) + 1})
  
long_side, short_side = 0, 0
for l, c in sorted(list(l_count.items()), reverse=1):
    if c != 1:
        if not long_side:
            if c >= 4:
                print((l ** 2))
                exit()
            else:
                long_side = l
        else:
            short_side = l
            break

print((long_side * short_side))

# Optimized solution
from sys import stdin

n, *a = list(map(int, stdin.read().split())) 

l_count = {}
for l in a:
    l_count.update({l: l_count.get(l, 0) + 1})
  
long_side, short_side = 0, 0
for l, c in sorted(list(l_count.items()), reverse=1):
    if c != 1:
        if not long_side:
            if c >= 4:
                print((l ** 2))
                exit()
            else:
                long_side = l
        else:
            short_side = l
            break

print((long_side * short_side))
# Original solution
import sys

n, *l = list(map(int, sys.stdin.read().split()))

def main():
    l.sort(reverse=True)

    a = b = 0
    i = 0
    while i <= n - 2:
        if l[i] == l[i+1]:
            if a:
                b = l[i]
                break
            else:
                a = l[i]
                i += 2
                continue
        i += 1
    
    return a * b

if __name__ == '__main__':
    ans = main()
    print(ans)

# Optimized solution
import sys

n, *a = list(map(int, sys.stdin.read().split()))

def main():
    a.sort()
    y = x = 0
    i = n - 1
    while i > 0:
        if a[i] == a[i-1]:
            if not y:
                y = a[i]
                i -= 1
            else:
                x = a[i]
                break
        i -= 1
    print((y * x))

if __name__ ==  '__main__':
    main()
# Original solution
N = int(eval(input()))
P = list(map(int,input().split()))
P.sort(reverse=True)
a = 0
b = 0
for i in range(N-1):
    if P[i] > 0:
        if a == 0:
            if P.count(P[i]) >= 2:
                a = P[i]
                P[i] = -i
                P[i+1] = -i -1
        elif b == 0:
            if P.count(P[i]) >= 2:
                b = P[i]
                P[i] = -i
                P[i+1] = -i -1
        else:
            break
    else:
        continue
ans = a * b
print(ans)

# Optimized solution
N = int(eval(input()))
P = list(map(int,input().split()))
P.sort(reverse=True)
a = 0
b = 0
for i in range(N-1):
    if P[i] > 0:
        if a == 0:
            if P[i] == P[i+1]:
                a = P[i]
                P[i] = -i
                P[i+1] = -i -1
        elif b == 0:
            if P[i] == P[i+1]:
                b = P[i]
                P[i] = -i
                P[i+1] = -i -1
        else:
            break
    else:
        continue
ans = a * b
print(ans)
# Original solution
import collections

N = int(eval(input()))
A = sorted(list(map(int,input().split())), reverse = True)
edge = []

for i in range(N):
    a = A[i]
    if A.count(a) >= 2 and a not in edge:
        edge.append(a)
        if len(edge) == 2:
            print((edge[0]*edge[1]))
            exit()
        if A.count(a) >= 4:
            print((a*a))
            exit()
print((0))


# Optimized solution
import collections

N = int(eval(input()))
A = list(map(int,input().split()))
B = collections.Counter(A)
C = []
for a,c in list(B.items()):
    C += [a] * (c//2)
C.sort()

if len(C) >= 2:
    print((C[-1]*C[-2]))
else:
    print((0))
# Original solution
from collections import defaultdict
N = int(eval(input()))
A = list(map(int, input().split()))
d = defaultdict(int)
for i in A:
    d[i] += 1
d = [x for x in list(d.items()) if x[1]>=2]

ans = 0
for i1,j1 in d:
    for i2,j2 in d:
        if j1 >= 2 and j2 >= 2 and i1 != i2:
            ans = max(ans,i1*i2)
        elif i1==i2 and j1>=4 and j2>=4:
            ans = max(ans,i1*i2)
print(ans)


# Optimized solution
N = int(eval(input()))
a = list(map(int, input().split()))
a.sort(reverse=True)
b = []
i = 0
while i+1<N:
    if len(b)==2:
        break
    if a[i] == a[i+1]:
        b += [a[i]]
        i += 2
    else:
        i += 1

if len(b)<2:
    print((0))
else:
    print((b[0]*b[1]))
# Original solution
from collections import Counter
N = int(eval(input()))
A = list(map(int,input().split()))
C = sorted(Counter(A).most_common(),reverse=True)
D = list([x for x in C if x[1]>=2])
if len(D)<2:
    print((0))
else:
    print((D[0][0]**2 if D[0][1]>=4 else D[0][0]*D[1][0]))

# Optimized solution
N = int(eval(input()))
A = list(map(int,input().split()))

from collections import Counter

# 2本以上ある棒のみ集計
C = Counter(A).most_common()
D = []
for (k,v) in C:
    if v>=2:
        D.append((k,v))

D.sort()

# 一番長い棒が4本あれば正方形(も長方形のうち)
if len(D)>=1 and D[-1][1]>=4:
    print((D[-1][0]**2))
elif len(D)>=2:
    print((D[-1][0]*D[-2][0]))
else:
    print((0))
# Original solution
from itertools import combinations


n = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
a = [i for i in a if a.count(i) > 1]
b = [j for j in a if a.count(j) > 3]
a = set(a)
b = set(b)
a -= b
a = list(a)
b = list(b)
for v in combinations(a, 2):
    ans = max(ans, v[0] * v[1])
for s in range(len(b)):
    ans = max(ans, s ** 2)
print(ans)

# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split()))
d = {}
for x in a:
    d[x] = d.get(x, 0) + 1
l = []
ans = 0
for num, cnt in sorted(list(d.items()), key=lambda x: x[0], reverse=True):
    if cnt > 3:
        if len(l) == 0:
            ans = num ** 2
            print(ans)
            exit()
        else:
            l.append(num)
            ans = l[0] * l[1]
            print(ans)
            exit()
    elif cnt > 1:
        l.append(num)
        if len(l) == 2:
            ans = l[0] * l[1]
            print(ans)
            exit()
print(ans)
# Original solution
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]))


# Optimized solution
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))
# Original solution
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    from collections import Counter
    c = Counter(A)
    li = [(k, v) for k, v in c.items() if v >= 2]
    li.sort(reverse=True)
    if li and li[0][1] >= 4:
        return print(li[0][0] * li[0][0])
    elif len(li) <= 1:
        return print(0)
    else:
        return print(li[0][0] * li[1][0])


if __name__ == '__main__':
    main()


# Optimized solution
def main():
    _ = int(eval(input()))
    A = [int(i) for i in input().split()]
    from collections import Counter
    c = Counter(A)
    li = [(k, v) for k, v in list(c.items()) if v >= 2]
    li.sort(reverse=True)
    if li and li[0][1] >= 4:
        print((li[0][0] * li[0][0]))
    elif len(li) <= 1:
        print((0))
    else:
        print((li[0][0] * li[1][0]))


if __name__ == '__main__':
    main()
# Original solution
from collections import Counter

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

counter = sorted(
    list(Counter(A).items()),
    key=lambda x:x[0],
    reverse=True)

ans = 1
cnt = 0
for length, num in counter:
    if cnt >= 2:
        break
    if num >= 4 and cnt == 0:
        print((length**2))
        exit()
    if num >= 2:
        ans *= length
        cnt += 1

if cnt == 2:
    print(ans)
else:
    print((0))


# Optimized solution
from collections import Counter

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

# 長さと個数の辞書
length_num = Counter(A)
# 長い順からの長さのリスト
lengths = sorted(list(length_num.keys()), reverse=True)

ans = 0
sides = []

# 長い辺の順にループ
for l in lengths:
  if length_num[l] >= 4:
    ans = max(ans, l * l)
  if length_num[l] >= 2:
    sides.append(l)
  if len(sides) == 2:
    ans = max(ans, sides[0] * sides[1])
    break

print(ans)
# Original solution
def main():
    N = int(eval(input()))
    a = [int(i) for i in input().split()]
    area = 0
    u_len = []

    #sort_a = sorted(set(a), reverse=True)
    #print(sort_a)
    max_num = max(a)
    for num in range(max_num, 0, -1):
        #print(num)
        c_num = a.count(num)
        if(c_num >= 4):
            area = num**2
            break
        elif(c_num >= 2):
            u_len.append(num)
            if(len(u_len) >= 2):
                area = u_len[0] * u_len[1]
                break
    
    print(area)
    
if __name__=="__main__":
    main()

# Optimized solution
def main():
    N = int(eval(input()))
    a = [int(i) for i in input().split()]
    area = 0
    
    b = 0
    tmp = 0

    sort_a = sorted(a, reverse=True)
    for num in sort_a:
        if(num == tmp):
            if(b > 0):
                area = num * b
                break
            else:
                b = num
                tmp = 0
        else:
            tmp = num
    
    print(area)
    
if __name__=="__main__":
    main()
# Original solution
n = int(eval(input()))
a = list(map(int,input().split()))
a.sort(reverse=True)
ans=[]
i=0
while i<n-1:
    if a[i]==a[i+1]:
        ans.append(a[i])
        i+=1
    i+=1
if len(ans) >= 2:
    print((ans[0]*ans[1]))    
else:
    print((0))

# Optimized solution
n = int(eval(input()))
a = list(map(int,input().split()))
a.sort(reverse=True)
flag=True
for i in range(0,n-4+1):
    if a[i]==a[i+1]:
        for j in range(i+2,n-1+1):
            if a[j]==a[j+1]:
                print((a[i]*a[j]))
                flag=False
                break
        break
if flag:
    print((0))
# Original solution
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

n = int(eval(input()))
a = list(map(int,input().split()))
x = [0 for i in range(max(a)+1)]
for i in range(n):
    x[a[i]]+=1
li2 = [0]
li4 = [0]
for i in range(len(x)):
    if x[i]>=4:
        li4.append(i)
    elif x[i]>=2:
        li2.append(i)
ans = li4[-1]**2
ans2 = 0
if len(li2)>=2:
    ans2 = li2[-1]*li2[-2]
else:
    ans2 = 0
print((max(ans,ans2)))

# Optimized solution
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

n = int(eval(input()))
a = list(map(int,input().split()))
c = collections.Counter(a)
li2 = [0,0]
li4 = [0]
for key,value in list(c.items()):
    if value>=4:
        li4.append(key)
    elif value>=2:
        li2.append(key)
li2.sort()
li4.sort()
ans1 = li2[-1]*li2[-2]
ans2 = li4[-1]**2
ans3 = li4[-1]*li2[-1]
ans = max(ans1,ans2)
ans = max(ans,ans3)
print(ans)
# Original solution
# ABC071-C　
N = int(eval(input()))
A_list = list(map(int, input().split()))

A_set = sorted(set(A_list), reverse = True)

side_list = [0, 0]

for i in range(len(A_set)):   # 大きい順に取っていき，リストで個数を確認する
    if len(side_list) >= 4:
        break
    count = A_list.count(A_set[i])    # リストの個数を確認
    if count == 2 or count == 3:
        side_list.append(A_set[i])
    if count >= 4:
        side_list.append(A_set[i])
        side_list.append(A_set[i])
        
side_list.sort(reverse = True)
print((side_list[0] * side_list[1]))

# Optimized solution
# ABC071-C
N = int(eval(input()))
A = sorted(list(map(int, input().split())), reverse = True)

for i in range(N-1):
    if A[i] == A[i+1]:
        A[i+1] = 0
    elif A[i] != A[i+1]:
        A[i] = 0
A.sort(reverse = True)
print((A[0] * A[1]))
# Original solution
n = int(eval(input()))
list1 = [int(x) for x in input().split()]


set1 = set(list1)


listans = []

for i in set1:
  if list1.count(i) > 1 and list1.count(i) < 4:
    listans.append(i)
  elif list1.count(i) >3:
    listans.append(i)
    listans.append(i)


if len(listans) < 2:
  print((0))
else:
  print((sorted(listans)[-1]*sorted(listans)[-2]))

# Optimized solution
n = int(eval(input()))
list1 = [int(x) for x in input().split()]
list2 = list(reversed(sorted(list1)))

fflag = 0
ans = []
for i in range(len(list2) - 1):
  if fflag ==0:
    if list2[i] == list2[i + 1]:
      ans.append(list2[i])
      fflag = 1
  elif fflag == 1:
    fflag = 0
    continue
  if len(ans) == 2:
    break

if len(ans) == 2:
  print((ans[0] * ans[1]))
else:
  print((0))
# Original solution
from collections import Counter
import sys
n = int(eval(input()))
a = list(map(int, input().split()))
count_a = list(Counter(a).items())
count_a = sorted(count_a, reverse=True)
result = 1
c = 0
for x, y in count_a:
    if y>=2:
        result *= x
        c += 1
        if y>=4 and c == 1:
            result *= x
            c += 1
        if c == 2:
            print(result)
            sys.exit()
print((0))

# Optimized solution
from collections import Counter
import sys
n = int(eval(input()))
a = list(map(int, input().split()))
count_a = list(Counter(a).items())
count_a = sorted(count_a, reverse=True)
result = 1
c = 0
for x, y in count_a:
    if y>=2:
        result *= x
        c += 1
        if c == 1 and y>=4:
            result *= x
            c += 1
        if c == 2:
            print(result)
            sys.exit()
print((0))
# Original solution
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list([int(x)-1 for x in stdin.readline().split()])
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
alp = [chr(ord('a') + i) for i in range(26)]
#A
def A():
    x, a, b = LI()
    if abs(x - a) > abs(x - b):
        print("B")
    else:
        print("A")
    return

#B
def B():
    s = S()
    s = set(s)
    for i in s:
        alp.remove(i)
    if len(alp) == 0:
        print("None")
    else:
        print((alp[0]))
    return

#C
def C():
    n = II()
    a = LI()
    i = 1
    a.sort(reverse=True)
    ans = []
    while i < n:
        if a[i] == a[i - 1]:
            ans.append(a[i])
            if len(ans) == 2:
                print((ans[0] * ans[1]))
                return
            i += 2
        else:
            i += 1
    print((0))

#D
def D():
    return

#Solve
if __name__ == '__main__':
    C()


# Optimized solution
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list([int(x)-1 for x in input().split()])
def II(): return int(eval(input()))
def IF(): return float(eval(input()))
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#solve
def solve():
    n = II()
    a = LI()
    d = defaultdict(int)
    for ai in a:
        d[ai] += 1
    lis = list(d.items())
    ans = []
    for i,j in lis:
        for _ in range(j // 2):
            ans.append(i)
    ans.sort(reverse=True)
    if len(ans) < 2:
        print((0))
    else:
        print((ans[0]*ans[1]))

    return


#main
if __name__ == '__main__':
    solve()
# Original solution
import math
import calendar
import fractions
import itertools

n = int(eval(input()))
a = list(map(int, input().split()))
b = sorted(set(a))[::-1]
ans = 1
cnt = 0
for i in b:
    if cnt == 2:
        break
    if a.count(i) < 2:
        continue
    if cnt == 1:
        ans *= i
        cnt += 1
        break
    if a.count(i) >= 4:
        ans = i ** 2
        cnt = 2
        break
    ans *= i
    cnt += 1

if cnt < 2:
    ans = 0
print(ans)

# Optimized solution
import math
import calendar
import fractions
import itertools

n = int(eval(input()))
a = sorted(map(int, input().split()), reverse=True)
h = 0
w = 0
index = -1
for i in range(n - 3):
    if a[i] == a[i + 1]:
        h = a[i]
        index = i + 2
        break

for i in range(index, n - 1):
    if a[i] == a[i + 1]:
        w = a[i]
        break

print((h * w))
# Original solution
from collections import Counter

N = int(eval(input()))
A = [int(x) for x in input().split()]

c = Counter(A)
ans = []
for k, v in sorted(list(c.items()), reverse=True):
    if v > 3 and len(ans) == 0:
        ans.append(k)
        ans.append(k)
    elif v > 1:
        ans.append(k)
    if len(ans) == 2:
        break

if len(ans) == 2:
    print((ans[0] * ans[1]))
else:
    print((0))

# Optimized solution
from collections import Counter

N = int(eval(input()))
A = [int(x) for x in input().split()]

ans = []
for k, v in sorted(list(Counter(A).items()), reverse=True):
    if v >= 4:
        ans.append(k)
        ans.append(k)
    elif v >= 2:
        ans.append(k)
    if len(ans) >= 2:
        break
if len(ans) >= 2:
    print((ans[0] * ans[1]))
else:
    print((0))