qyliang/CodeNanoFix huggingface dataset:
# Buggy code:
#B Collecting Balls (Easy Version)
n = int(input())
k = int(input())
l = list(map(int, input().split()))
for i in range(n):
    l[i] = min(l[i],abs(l[i]-k))
print(sum(l))

# Fixed code:
#B Collecting Balls (Easy Version)
n = int(input())
k = int(input())
l = list(map(int, input().split()))
for i in range(n):
    l[i] = min(l[i],abs(l[i]-k))*2
print(sum(l))
# Buggy code:
n = int(input())
k = int(input())
x = map(int,input().split())
ans = 0
for i in range(n):
    ans += min(abs(x[i]-k),x[i])
print(ans*2)


# Fixed code:
n = int(input())
k = int(input())
x = [int(i) for i in input().split()]
ans = 0
for i in range(n):
    ans += 2 * min(x[i],k-x[i])
print(ans)
# Buggy code:
N = int(input())
K = int(input())
l = list(map(int, input().split()))

ans = 0
for i in l:
  ans += min([K-l, l])*2
  
print(ans)

# Fixed code:
N = int(input())
K = int(input())
l = list(map(int, input().split()))

ans = 0
for i in l:
  ans += min([K-i, i])*2
  
print(ans)
# Buggy code:
n = int(input())
k = int(input())
l = map(int,input().split())
print(sum(min(i,k-i) for i in range(n))*2)

# Fixed code:
input()
k = int(input())
l = map(int,input().split())
print(sum(min(i,k-i) for i in l)*2)
# Buggy code:

N = int(input())
K = int(input())
x = list(map(int, input().split()))
K_half =  10/2

total=0

for i in range(N):
    if K_half>=x[i]:
        total = total + x[i]*2
    else:
        total = total + (K-x[i])*2
print(total)

# Fixed code:

N = int(input())
K = int(input())
x = list(map(int, input().split()))
K_half =  K/2

total=0

for i in range(N):
    if K_half>=x[i]:
        total = total + x[i]*2
    else:
        total = total + (K-x[i])*2
print(total)
# Buggy code:
a=int(input())
b=int(input())
c=list(map(int,input().split()))
total=0
for i in range(2):
    d=2*c[i]
    e=2*abs(9-c[i])
    total+=min(d,e)
print(total)

# Fixed code:
a=int(input())
b=int(input())
c=list(map(int,input().split()))
total=0
for i in range(a):
    d=2*c[i]
    e=2*abs(b-c[i])
    total+=min(d,e)
print(total)
# Buggy code:
n = int(input())
k = int(input())
x = list(map(int,input().split()))
ans = 0

for i in x:
  ans += min(abs(x-k),x)
  
print(ans)

# Fixed code:
n = int(input())
k = int(input())
x = list(map(int,input().split()))
ans = 0
for i in x:
    ans += min(i*2,abs(i-k)*2)
print(ans)
# Buggy code:
N = int(input())
K = int(input())
X = list(map(int, input().split()))

line = K // 2
ans = 0

for x in X:
	if x <= line:
		ans += x
	else:
		ans += K - line
ans *= 2
print(ans)

# Fixed code:
N = int(input())
K = int(input())
X = list(map(int, input().split()))

line = K // 2
ans = 0

for x in X:
	if x <= line:
		ans += x
	else:
		ans += (K - x)
ans *= 2
print(ans)
# Buggy code:
n = int(input())
k = int(input())
xxx = list(map(int, input().split()))
ans = sum(min(x, abs(k - x)) for x in xxx)
print(ans)

# Fixed code:
n = int(input())
k = int(input())
xxx = list(map(int, input().split()))
ans = sum(min(x, abs(k - x)) for x in xxx) * 2
print(ans)
# Buggy code:
import collections

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

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


# Fixed code:
import collections

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

if len(C) >= 2:
    print(C[-1]*C[-2])
else:
    print(0)
# Buggy code:
import sys
input=sys.stdin.readline
import collections

input = open(sys.argv[1], "r").readline

def main():
    N = int(input())
    A = list(map(int,input().split()))
    d = collections.defaultdict(int)
    for a in A:
        d[a] += 1
    for k,v in list(d.items()):
        if v < 2:
            d.pop(k)
    d = sorted(d.items(), key=lambda x: x[0], reverse=True)
    if len(d) >= 1 and d[0][1] >= 4:
        print(d[0][0]**2)
    elif len(d) >= 2:
        print(d[0][0]*d[1][0])
    else:
        print(0)

if __name__ == '__main__':
    main()


# Fixed code:
import sys
input=sys.stdin.readline
import collections

def main():
    N = int(input())
    A = list(map(int,input().split()))
    d = collections.defaultdict(int)
    for a in A:
        d[a] += 1
    for k,v in list(d.items()):
        if v < 2:
            d.pop(k)
    d = sorted(d.items(), key=lambda x: x[0], reverse=True)
    if len(d) >= 1 and d[0][1] >= 4:
        print(d[0][0]**2)
    elif len(d) >= 2:
        print(d[0][0]*d[1][0])
    else:
        print(0)

if __name__ == '__main__':
    main()
# Buggy code:
N=int(input())
A=list(map(int, input().split()))

A.sort(reverse=True)

j=0
prev=A[0]

longer_edge=0

for i,a in enumerate(A):
  if a==prev:
    pass
  else:
    if not longer_edge:
      if (j-i)>=4:
        print(a**2)
        exit()
      elif (j-i)>=2:
        longer_edge=a
    elif longer_edge:
      if (j-i)>=2:
        print(a*longer_edge)
    prev=a

# Fixed code:
N=int(input())
A=list(map(int, input().split()))

A.sort(reverse=True)

j=0
prev=A[0]

longer_edge=0

for i,a in enumerate(A+[0,0,0,0,-1]):
  if a==prev:
    pass
  else:
    if not longer_edge:
      if (i-j)>=4:
        print(prev**2)
        exit()
      elif (i-j)>=2:
        longer_edge=prev
    elif longer_edge:
      if (i-j)>=2:
        print(prev*longer_edge)
        exit()
    prev=a
    j=i
# Buggy code:
N = int(input())
A = [int(x) for x in input().split()]

from collections import Counter
Aco = Counter(A)

ing = []
ing2 = []
for a in Aco.keys() :
    if Aco[a] >= 2 :
        ing.append(a)
    if Aco[a] >= 4 :
        ing2.append(a)

ing.sort(reverse = True)
ing2.sort(reverse = True)
if ing2 :
    print(ing2[0]**2)
else :
    if len(ing) <= 1 :
        print(0)
    else :
        print(ing[0] * ing[1])


# Fixed code:
N = int(input())
A = [int(x) for x in input().split()]

from collections import Counter
Aco = Counter(A)

ing = []
ing2 = []
for a in Aco.keys() :
    if Aco[a] >= 2 :
        ing.append(a)
    if Aco[a] >= 4 :
        ing2.append(a)

ing.sort(reverse = True)
ing2.sort(reverse = True)
if ing2 :
    if ing2[0] == ing[0] :
        print(ing2[0]**2)
        exit()

if len(ing) <= 1 :
    print(0)
else :
    print(ing[0] * ing[1])
# Buggy code:
N = int(input())
sticks = list(map(int, input().split()))
s_dict = {}
for stick in sticks:
  if stick in s_dict:
    s_dict[stick] += 1
  else:
    s_dict[stick] = 1
sorted_dict = sorted(s_dict.items(), key=lambda:-x[0])
side1 = 0
side2 = 0
for elem in sorted_dict:
  if elem[1] >= 4:
    side1 = side2 = elem[0]
  elif elem[1] == 2 or elem[1] == 3:
    if side1 == 0:
      side1 = elem[0]
    else:
      side2 = elem[0]
  if side1 != 0 and side2 != 0:
    print(side1*side2)
    exit()
print(0)

# Fixed code:
N = int(input())
sticks = list(map(int, input().split()))
s_dict = {}
for stick in sticks:
  if stick in s_dict:
    s_dict[stick] += 1
  else:
    s_dict[stick] = 1
sorted_dict = sorted(s_dict.items(), key=lambda x:-x[0])
side1 = 0
side2 = 0
for elem in sorted_dict:
  if elem[1] >= 4:
    if side1 == 0:
      side1 = side2 = elem[0]
    else:
      side2 = elem[0]
  elif elem[1] == 2 or elem[1] == 3:
    if side1 == 0:
      side1 = elem[0]
    else:
      side2 = elem[0]
  if side1 != 0 and side2 != 0:
    print(side1*side2)
    exit()
print(0)
# Buggy code:
N = int(input())
A = [int(a) for a in input().split(" ")]

A.sort(reverse=True)
l1 = 0
c1 = 0
l2 = 0
c2 = 0

L1 = 0
L2 = 0

for i in range(len(A)):
  print(" ".join([str(s) for s in [i, l1, c1, l2, c2, L1, L2]]))
  if L1 and L2:
    break
  elif L1:
    if l2 == A[i]:
      c2 += 1
    elif l2 != A[i]:
      l2 = A[i]
      c2 = 1
    if c2 == 2:
      L2 = l2
  else:
    if l1 == A[i]:
      c1 += 1
    elif l1 != A[i]:
      l1 = A[i]
      c1 = 1
    if c1 == 2:
      L1 = l1

print(L1 * L2)

# Fixed code:
N = int(input())
A = [int(a) for a in input().split(" ")]

A.sort(reverse=True)
l1 = 0
c1 = 0
l2 = 0
c2 = 0

L1 = 0
L2 = 0

for i in range(len(A)):
  if L1 and L2:
    break
  elif L1:
    if l2 == A[i]:
      c2 += 1
    elif l2 != A[i]:
      l2 = A[i]
      c2 = 1
    if c2 == 2:
      L2 = l2
  else:
    if l1 == A[i]:
      c1 += 1
    elif l1 != A[i]:
      l1 = A[i]
      c1 = 1
    if c1 == 2:
      L1 = l1

print(L1 * L2)
# Buggy code:
N = int(input())
A = list(map(int,input().split()))
A.sort(reverse=True)
cnt = 0
prev = 0
candidates = []
for i in A:
    if i == prev:
        cnt += 1
    if cnt >= 3:
        print(i**2)
        exit()
    if cnt == 2:
        candidates.append(i)
    if len(candidates) == 2:
        print(candidates[0]*candidates[1])
        exit()
    if i != prev:
        prev = i
        cnt = 0
print(0)

# Fixed code:
N = int(input())
A = list(map(int,input().split()))
A.sort(reverse=True)
#print(A)
cnt = 0
prev = 0
candidates = []
for i in A:
    if i == prev:
        cnt += 1
        prev = i
    elif i != prev:
        prev = i
        cnt = 0
    if cnt >= 3:
        print(i**2)
        exit()
    if cnt == 1:
        candidates.append(i)
    if len(candidates) == 2:
        print(candidates[0]*candidates[1])
        exit()

print(0)
# Buggy code:
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
pin=a[0]
cnt=1
x=[]
for i in range(1,n):
  if a[i]==pin:
    cnt+=1
  else:
    if cnt>=4:
      x+=[pin]
      x+=[pin]
    elif cnt>=2:
      x+=[pin]
    if len(x)>=2:
      break
    pin=a[i]
    
if len(x)<=1:
  print(0)
else:
  print(x[0]*x[1])

# Fixed code:
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
pin=a[0]
cnt=1
x=[]
for i in range(1,n):
  if a[i]==pin and i!=(n-1):
    cnt+=1
  elif a[i]!=pin:
    if cnt>=4:
      x+=[pin]
      x+=[pin]
    elif cnt>=2:
      x+=[pin]
    if len(x)>=2:
      break
    pin=a[i]
    cnt=1
  
  elif i==(n-1):
    if pin==a[i]:
      cnt+=1
    if cnt>=4:
      x+=[pin]
      x+=[pin]
    elif cnt>=2:
      x+=[pin]
    if len(x)>=2:
      break
    pin=a[i]
    cnt=1

    
if len(x)<=1:
  print(0)
else:
  print(x[0]*x[1])
# Buggy code:
n = int(input())
a = list(map(int,input().split()))

a.sort(reverse=True)
for i in range(len(a)-1):
    if a[i] == a[i+1]:
        a1 = a[i]
        break
    elif i == len(a)-2:
        print(0)
        exit()
    else:
        continue
b = []
for i in range(len(a)):
    if a[i] == a1:
        continue
    else:
        b.append(a[i])
b.sort()
for i in range(len(b)-1):
    if b[i] == b[i+1]:
        a2 = b[i]
        break
    elif i == len(b)-2:
        print(0)
        exit()
    else:
        continue
print(a1*a2)

# Fixed code:
n = int(input())
a = list(map(int,input().split()))

a.sort(reverse=True)
for i in range(len(a)-1):
    if a[i] == a[i+1]:
        a1 = a[i]
        break
    elif i == len(a)-2:
        print(0)
        exit()
    else:
        continue
b = []
l=0
for i in range(len(a)):
    if a[i] == a1 and l<2:
        l += 1
    else:
        b.append(a[i])
b.sort(reverse=True)
for i in range(len(b)-1):
    if b[i] == b[i+1]:
        a2 = b[i]
        break
    elif i == len(b)-2:
        print(0)
        exit()
    else:
        continue
print(a1*a2)
# Buggy code:
n=int(input())
a=list(map(int,input().split()))

e=[]
a.sort()
for i in range(len(a)-1):
  if a[i] == a[i+1]:
    e.append(a[i])
e.sort(reverse=True)

c4 = 0
for i in e:
  if a.count(i)>=4:
    c4=i
    break

if c4 == 0 and len(e)<2:
  print(0)
elif c4 == 0 and len(e)>=2:
  print(e[0]*e[1])
elif c4 > 0 and len(e)<2:
  print(c4**2)
else:
  print(max(c4**2,e[0]*e[1]))

# Fixed code:
n=int(input())
a=list(map(int,input().split()))

e=[]
a.sort(reverse=True)
for i in range(len(a)-1):
  if a[i] == a[i+1] and a[i] not in e:
    e.append(a[i])
    if len(e) == 2:
      break
e.sort(reverse=True)

c4 = 0
for i in e:
  if a.count(i)>=4:
    c4=i
    break

if c4 == 0 and len(e)<2:
  print(0)
elif c4 == 0 and len(e)>=2:
  print(e[0]*e[1])
elif c4 > 0 and len(e)<2:
  print(c4**2)
else:
  print(max(c4**2,e[0]*e[1]))
# Buggy code:

def C():
    n = int(input())
    a = sorted(list(map(int,input().split())),reverse=True)
    i=0
    print(a)
    longer = 0
    shorter = 0
    while i < len(a)-1:
        print(i,a[i])
        if a[i] == a[i+1]:
            if longer == 0:
                longer = a[i]
                i+=1
            elif shorter == 0:
                shorter = a[i]
                i+=1
        i+=1
    print(longer*shorter)
C()

# Fixed code:

def C():
    n = int(input())
    a = sorted(list(map(int,input().split())),reverse=True)
    i=0
    longer = 0
    shorter = 0
    while i < len(a)-1:
        if a[i] == a[i+1]:
            if longer == 0:
                longer = a[i]
                i+=1
            elif shorter == 0:
                shorter = a[i]
                i+=1
        i+=1
    print(longer*shorter)
C()
# Buggy code:
n=int(input())
a=list(map(int,input().split()))
from collections import Counter
c=Counter(a).items()
f=0
s=0
for k,v in c:
    if v>=4:
        if v>f:
            s=v
            f=v
        elif v>s:
            s=v
    if v>=2:
        if v>f:
            s=f
            f=v
        elif v>s:
            s=v

print(s*f)


# Fixed code:
n=int(input())
a=list(map(int,input().split()))
from collections import Counter
c=Counter(a).items()
f=0
s=0
for k,v in c:
    if v>=4:
        if k>f:
            s=k
            f=k
        elif k>s:
            s=k
    if v>=2:
        if k>f:
            s=f
            f=k
        elif k>s:
            s=k

print(s*f)
# Buggy code:
def solve(): # 071C - Make a Rectangle
    n = int(input())
    sides = list(map(int, input().split(" ")))
    check_dual = {}
    possible_sides = []

    for i in sides:
        if i in check_dual:
            check_dual[i] += 1
        else:
            check_dual[i] = 1

    for k, v in check_dual.items():
        if v >=4:
            possible_sides.append(k)
            possible_sides.append(k)
        elif v == 2 or v == 3:
            possible_sides.append(k)

    possible_sides.sort(reverse=True)
    if len(possible_sides) < 2:
        print(0)
    else:
        print(possible_sides[0] * possible_sides[1])

# Fixed code:
def solve(): # 071C - Make a Rectangle
    n = int(input())
    sides = list(map(int, input().split(" ")))
    check_dual = {}
    possible_sides = []

    for i in sides:
        if i in check_dual:
            check_dual[i] += 1
        else:
            check_dual[i] = 1

    tmp_square = 0
    for k, v in check_dual.items():
        if v >= 4 and k > tmp_square:
            tmp_square = k
            possible_sides.append(k)
        elif v == 2 or v == 3:
            possible_sides.append(k)
        else:
            pass

    possible_sides.sort(reverse=True)
    if tmp_square == 0 and len(possible_sides) < 2:
        print(0)
    elif tmp_square != 0 and len(possible_sides) == 0:
        print(tmp_square ** 2)
    elif tmp_square != 0 and len(possible_sides) == 1:
        print(max(tmp_square ** 2, tmp_square * possible_sides[0]))
    else:
        print(max(tmp_square ** 2, possible_sides[0] * possible_sides[1]))

solve()
# Buggy code:
from collections import Counter
n, *A = map(int, open(0).read().split())
B = sorted([(k, v) for k, v in Counter(A).items() if v >= 2], reverse=1)
if len(B) == 0:
  print(0)
elif len(B) == 1:
  if B[0][1] >= 4:
  	print(B[0][0] ** 2)
  else:
    print(0)
else:
  if B[0][1] >= 4:
  	print(B[0][0] ** 2)
  else:
  	print(B[0]*B[1])

# Fixed code:
from collections import Counter
n, *A = map(int, open(0).read().split())
B = sorted([(k, v) for k, v in Counter(A).items() if v >= 2], reverse=1)
if len(B) == 0:
  print(0)
elif len(B) == 1:
  if B[0][1] >= 4:
  	print(B[0][0] ** 2)
  else:
    print(0)
else:
  if B[0][1] >= 4:
  	print(B[0][0] ** 2)
  else:
  	print(B[0][0]*B[1][0])
# Buggy code:
from collections import Counter

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

c = Counter(A)
pair = []
print(c)
for x, cnt in c.items():
    pair += [x] * (cnt//2)

# print(pair)
pair.sort()

ans = 0
if len(pair) >= 2:
    ans = pair[-1] * pair[-2]
print ans

# Fixed code:
from collections import Counter

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

c = Counter(A)
pair = []
# print(c)
for x, cnt in c.items():
    pair += [x] * (cnt//2)

# print(pair)
pair.sort()

ans = 0
if len(pair) >= 2:
    ans = pair[-1] * pair[-2]
print(ans)
# Buggy code:
N = int(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.sort()
A.reverse()
print(A[0] * A[1])


# Fixed code:
N = int(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])
# Buggy code:
N = int(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
print(b[0]*b[1])

# Fixed code:
N = int(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])
# Buggy code:
n = int(input())
A = list(map(int,input().split()))
A.sort(reverse=True)
switch = 1
ans = []

for i in range(n-1):
    if switch == 1:
        if A[i] == A[i+1]:
            ans.append(A[i])
            switch = 0
    if switch == 0:
        switch = 1

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

# Fixed code:
n = int(input())
A = list(map(int,input().split()))
A.sort(reverse=True)
switch = 1
ans = []

for i in range(n-1):
    if switch == 1:
        if A[i] == A[i+1]:
            ans.append(A[i])
            switch = 0
    else: 
        switch = 1

if len(ans)>=2:
    print(ans[0]*ans[1])
else:
    print(0)
# Buggy code:
N = int(input())
A = sorted(list(map(int, input().split())))

from collections import Counter
c = Counter(A)
w = 0
h = 0
print(sorted(c.items(), key=lambda x: -x[0]))
for k, v in sorted(c.items(), key=lambda x: -x[0]):
    if v >= 4:
        if w == 0:
            w = h = k
        else:
            h = k
            break
    if v >= 2:
        if w == 0:
            w = k
        elif h == 0:
            h = k
            break
print(w*h)

# Fixed code:
N = int(input())
A = sorted(list(map(int, input().split())))

from collections import Counter
c = Counter(A)
w = 0
h = 0
for k, v in sorted(c.items(), key=lambda x: -x[0]):
    if v < 2:
        continue
    if v >= 4:
        if w == 0:
            w = h = k
            break
        else:
            h = k
            break
    elif v >= 2:
        if w == 0:
            w = k
        elif h == 0:
            h = k
            break
print(w*h)
# Buggy code:
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
bn = 0
ans = 0
count = 0
i = 0

while(i<n):
    print(a[i],i,ans)
    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)

# Fixed code:
n = int(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)
# Buggy code:
N = int(input())
A = list(map(int, input().split()))

bar_length_count = dict()
for a in A:
    bar_length_count[a] = bar_length_count.get(a, 0) + 1

for val in bar_length_count.values():
    pass

count_at_least_2 = 0
for val in bar_length_count.values():
    if val >= 2:
        if val >= 4:
            count_at_least_2 += 2
        else:
            count_at_least_2 += 1

if count_at_least_2 < 2:
    import sys
    print(0)
    sys.exit(0)

else:
    bar_length_count = sorted({k:v for bar_length_count.items() if v >= 2}, reverse=True)
    if bar_length_count[0][1] >= 4:
        print(bar_length_count[0][0]**2)
    else:
        print(bar_length_count[0][0]*bar_length_count[1][0])
        

# Fixed code:
N = int(input())
A = list(map(int, input().split()))

bar_length_count = dict()
for a in A:
    bar_length_count[a] = bar_length_count.get(a, 0) + 1

for val in bar_length_count.values():
    pass

count_at_least_2 = 0
for val in bar_length_count.values():
    if val >= 2:
        if val >= 4:
            count_at_least_2 += 2
        else:
            count_at_least_2 += 1

if count_at_least_2 < 2:
    import sys
    print(0)
    sys.exit(0)

else:
    bar_length_count = sorted({k:v for k, v in bar_length_count.items() if v >= 2}.items(), key=lambda x: x[0], reverse=True)
    if bar_length_count[0][1] >= 4:
        print(bar_length_count[0][0]**2)
    else:
        print(bar_length_count[0][0]*bar_length_count[1][0])
# Buggy code:
import collections

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

stick_num = collections.Counter(A)
flag = True
ans = 0
for i in sorted(stick_num, reverse=True):
    if stick_num[i] % 4 == 0:
        ans = i * i
    elif stick_num[i] % 2 >= 0:
        if flag:
            a = i
            flag = False
        else:
            ans = a * i
            break

print(ans)

# Fixed code:
import collections

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

stick_num = collections.Counter(A)
flag = True
ans = 0
for i in sorted(stick_num, reverse=True):
    if stick_num[i] >= 4:
        ans = i * i if flag else a * i
        break
    elif stick_num[i] >= 2:
        if flag:
            a = i
            flag = False
        else:
            ans = a * i
            break

print(ans)
# Buggy code:
import collections

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

A = collections.Counter(A).most_common()
N = len(A)

ans = [0]

for i in range(N):
    if A[i][1] >= 4:
        ans.append(A[i][0]**2)

ref = []
for j in range(N):
    if A[i][1] >= 2:
        ref.append(A[i][0])

if len(ref) >= 2:
    ans.append(ref[0]*ref[1])

print(max(ans))

# Fixed code:
import collections

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

A = collections.Counter(A).most_common()
N = len(A)

ans = [0]

for i in range(N):
    if A[i][1] >= 4:
        ans.append(A[i][0]**2)

ref = []
for j in range(N):
    if A[j][1] >= 2:
        ref.append(A[j][0])
ref = sorted(ref)
if len(ref) >= 2:
    ans.append(ref[-2]*ref[-1])

print(max(ans))
# Buggy code:
n = int(input())
a = list(map(int, input().split()))
a.sort()
a.reverse()

x, y = 0, 0

i = 0
while i < n - 1:
    if a[i] == a[i + 1]:
        x = a[i]
        i += 2
        break
    i += 1
n = int(input())
a = list(map(int, input().split()))
a.sort()
a.reverse()

x, y = 0, 0

i = 0
while i < n - 1:
    if a[i] == a[i + 1]:
        x = a[i]
        i += 2
        break
    i += 1

while i < n - 1:
    if a[i] == a[i + 1]:
        y = a[i]
        i += 2
        break
    i += 1
print(x * y)
while i < n - 1:
    if a[i] == a[i + 1]:
        y = a[i]
        i += 2
        break
    i += 1
print(x * y)

# Fixed code:
n = int(input())
a = list(map(int, input().split()))
a.sort()
a.reverse()

x, y = 0, 0

i = 0
while i < n - 1:
    if a[i] == a[i + 1]:
        x = a[i]
        i += 2
        break
    i += 1

while i < n - 1:
    if a[i] == a[i + 1]:
        y = a[i]
        i += 2
        break
    i += 1
print(x * y)
# Buggy code:
n=int(input())
a=list(map(int,input().split()))
a.sort()
stack=a[-1]
ans=[]
for i in range(n-2,-1,-1):
  if len(ans)==2:
    break
  if a[i]==stack:
    ans.append(stack)
  else:
    stack=a[i]
if len(ans)==2:
  print(ans[0]*ans[1])
else:
  print(0)

# Fixed code:
n=int(input())
a=list(map(int,input().split()))
a.sort()
stack=a[-1]
ans=[]
for i in range(n-2,-1,-1):
  if len(ans)==2:
    break
  if a[i]==stack:
    ans.append(stack)
    stack=-1
  else:
    stack=a[i]
if len(ans)==2:
  print(ans[0]*ans[1])
else:
  print(0)