Problem:
 Score : 300 points    Problem Statement We have N sticks with negligible thickness.
The length of the i -th stick is A_i .  Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides.
Find the maximum possible area of the rectangle.      Constraints  4 \leq N \leq 10^5  1 \leq A_i \leq 10^9  A_i is an integer.         Input Input is given from Standard Input in the following format:  N  A_1  A_2 ... A_N       Output Print the maximum possible area of the rectangle.
If no rectangle can be formed, print 0 .        Sample Input 1 6
3 1 2 4 2 1      Sample Output 1 2  1 \times 2 rectangle can be formed.       Sample Input 2 4
1 2 3 4      Sample Output 2 0  No rectangle can be formed.       Sample Input 3 10
3 3 3 3 4 4 4 5 5 5      Sample Output 3 20

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)

rec1,rec2,i=0,0,0
while i<n-1:
    if a[i]==a[i+1]:
        if rec1==0:
            rec1=a[i]
            i+=1
        else:
            rec2=a[i]
            break
    i+=1
print(rec1*rec2)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
a.sort()
tmp = []
i =n-1
while i >0:
    if a[i] == a[i-1]:
        tmp.append(a[i])
        i -=2
    else:
        i -=1
if len(tmp)>=2:
    print(tmp[0]*tmp[1])
else:
    print(0)

Solution (Python):
import collections
n = int(input())
a = list(map(str,input().split()))
c = collections.Counter(a)
set_a = set(a)
lists = []
for i in set_a:
    if int(c[i]) >= 2:
       lists.append(int(i))
    if int(c[i]) >= 4:
        lists.append(int(i))
lists.sort()
lists.reverse()
if len(lists) > 1:
    ans = int(lists[0]) * int(lists[1])
else:
    ans = 0
print(ans)

Solution (Python):
from collections import Counter
import sys
n = int(input())
a = Counter(list(map(int,input().split())))

lis = sorted(a.items(), key = lambda z: z[0], reverse = True)
ans = []
for i in lis:
    if len(ans) == 0 and i[1] >= 4:
        print(i[0]**2)
        sys.exit()
    elif i[1] >= 2 and len(ans) <= 1:
        ans.append(i[0])
    else:
        pass
if len(ans) == 2:
    print(ans[0] * ans[1])
else:
    print(0)

Solution (Python):
def main():
    sticks = int(input())
    stick_length = list(map(int, input().split()))
    length_count = {}
    for length in stick_length:
        if length in length_count:
            length_count[length] += 1
        else:
            length_count[length] = 1
    length_count = sorted(length_count.items(), key=lambda x: x[0], reverse=True)
    answer = 0
    for stick_info in length_count:
        if stick_info[1] < 2:
            continue
        elif stick_info[1] >= 4:
            if answer == 0:
                answer = stick_info[0] ** 2
                break
            else:
                answer *= stick_info[0]
                break
        else:
            if answer > 0:
                answer *= stick_info[0]
                break
            else:
                answer = stick_info[0]
    print(answer)


if __name__ == '__main__':
    main()

Solution (Python):
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
cnt = Counter(a)
ans = []
for i, v in cnt.items():
    if 2 <= v < 4:
        ans.append(i)
    elif 4 <= v:
        ans.append(i)
        ans.append(i)

if not ans:
    print(0)
else:
    ans.sort()
    x = ans.pop()
    y = ans.pop()
    print(x * y)

Solution (Python):
from collections import Counter
N = int(input())
A = [int(i) for i in input().split()]

l = []
c = Counter(A)
for k in c.keys():
    if c[k] >= 2:
        l.append(k)
    if c[k] >= 4:
        l.append(k)
l.sort(reverse=True)
if len(l) > 1:
    print(l[0]*l[1])
else:
    print(0)

Solution (Python):
from collections import Counter

n = int(input())
s = [int(x) for x in input().split()]

c = Counter(s)

c = sorted(c.items())

max1 = 0
max2 = 0
max3 = 0

for i in range(len(c)):
    if c[i][1] >= 2:
        if c[i][0] >= max2:
            if c[i][0] >= max1:
                max2 = max1
                max1 = c[i][0]
            else:
                max2 = c[i][0]

    if c[i][1] >= 4:
        max3 = c[i][0]

if max2 == 0:
    print("0")
else:
    print(max(max1*max2, max3**2))

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

A = sorted(A, reverse=True)

counter = 1
edge1 = 0
flag = 0

for i in range(len(A)-1):
    if edge1 == 0:
        edge1 = A[i]
    if counter == 4:
        print(edge1*edge1)
        break
    elif A[i] == A[i+1] and counter < 4:
        counter = counter + 1
    elif A[i] != A[i+1] and counter >= 2:
        flag = 1
        start = i
        break
    else:
        edge1 = 0
else:
    print(0)
if flag == 1:
    for i in range(start+1, len(A)-1):
        if A[i] == A[i+1]:
            print(edge1*A[i])
            break
    else:
        print(0)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)

tmp1=a[0]
for i in range(n-1):
    l,s= 0,0
    if tmp1 == a[i+1]:
        idx = i+1
        l = tmp1 
        
        tmp2=a[idx+1]
        for j in range(idx+1,n-1):
            if tmp2==a[j+1]:
                s = tmp2
                print(l*s)
                exit()
            else:
                tmp2 = a[j+1]
    else:
        idx=i
        tmp1=a[i+1]
        
print(0)

Solution (Python):
n = int(input())
a = [int(i) for i in input().split()]
d = {}
for i in range(n):
    if a[i] in d:
        d[a[i]] += 1
    else:
        d[a[i]] = 1

cnt = 0
ans = 0
for k, v in sorted(d.items(), key=lambda x: x[0], reverse=True):
    if v >= 4 and cnt == 0:
        ans = k ** 2
        break
    elif v >= 2:
        if cnt == 0:
            ans = k
            cnt += 1
        else:
            ans *= k
            break
print(ans)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))

dic = {}
for i in range(n):
    if a[i] in dic:
        dic[a[i]] += 1
    else:
        dic[a[i]] = 1

dic = sorted(dic.items(), key=lambda x:x[0])
dic.reverse()

ans = 0
cnt = 0
for i in range(len(dic)):
    if dic[i][1] >= 4 and cnt == 0:
        ans = dic[i][0] ** 2
        break
    elif dic[i][1] >= 2:
        if cnt == 0:
            ans = dic[i][0]
            cnt += 1
        else:
            ans = ans * dic[i][0]
            break
print(ans)

Solution (Python):
"""import collections
n=int(input())
a=list(map(int,input().split()))
ac=collections.Counter(a)

for k,i in ac.items():
"""
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
count=0
ans4=0
ans2=[0]*2
for i in range(n-1):
    
    if a[i]==a[i+1]:
        count+=1
    if i==(n-2) or a[i]!=a[i+1]:
        if 1<=count:
            if 3<=count:
                ans4=max(ans4,a[i])
                ans2.append(a[i])
            else:
                ans2.append(a[i])
        count=0
ans2.sort(reverse=True)

print(max(ans4**2,ans4*ans2[0],ans2[0]*ans2[1]))

Solution (Python):
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
c = Counter(A)
v = sorted([(key, value) for key, value in c.items() if value != 1],
           key=lambda x: x[0],
           reverse=True)

if len(v) <= 0:
    print(0)
    exit()
if len(v) == 1:
    if v[0][1] >= 4:
        print(v[0][0] * v[0][0])
    else:
        print(0)
    exit()
if v[0][1] >= 4:
    print(v[0][0] * v[0][0])
else:
    print(v[0][0] * v[1][0])

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
dic = {}
for a in A:
  if a in dic:
    dic[a] += 1
  else:
    dic[a] = 1
l = []
for k, v in dic.items():
  if v >= 2:
    l.append(k)
l.sort()
if len(l) == 0:
  print(0)
elif len(l) == 1:
  if dic[l[-1]] >= 4:
    print(l[-1] ** 2)
  else:
    print(0)
else:
  if dic[l[-1]] >= 4:
    print(l[-1] ** 2)
  else:
    print(l[-1] * l[-2])

Solution (Python):
def makerectangle(n , a):

    listmax = []
    a.sort(reverse=True)
    for i in range(n):
        if len(a) > i + 1 and a[i] == a[i + 1] and listmax.count(a[i]) == 0:
            if len(a) > i + 3 and a[i] == a[i + 3] and len(listmax) == 0:
                return a[i] * a[i]
            else:
                listmax.append(a[i])
        if len(listmax) > 1:
            return listmax[0] * listmax[1]
    return 0


def main():
    n = int(input())
    a = list(map(int,input().split()))
    print(makerectangle(n , a))

if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
l = list(map(int,input().split()))
l.sort(reverse=True)
a = 0
b = 0
check = -1
for i in range(n-1):
  if l[i]==l[i+1]:
    if check != i:
      if a == 0:
        a = l[i]
        check = i+1
      elif b == 0:
        b = l[i]
print(a*b)

Solution (Python):
import collections
N=int(input())
A=list(map(int,input().split()))
S = collections.Counter(A)
T=[]
sq=-1;r1=-1;r2=-1
T=S.most_common()
T.sort(reverse=True,key=lambda x: x[0])

for i in range(len(T)):
  if T[i][1]>3:
    if sq==-1:
      sq=i
      if r1==-1:
        r1=i
      else:
        if r2==-1:
          r2=i
  elif T[i][1]>1:
    if r1==-1:
      r1=i
    else:
      if r2==-1:
        r2=i

if r1!=-1 and r2!=-1:
  if sq!=-1:
    print(max(T[sq][0]**2,T[r1][0]*T[r2][0]))
  else:
    print(T[r1][0]*T[r2][0])
elif sq!=-1:
  print(T[sq][0]**2)
else:
  print(0)

Solution (Python):
from collections import defaultdict


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

A.sort()

dict = defaultdict(int)

count = 0
select = []
for _ in range(n):
    length = A.pop()

    if dict[length] > 0:
        dict[length] -= 1
        select.append(length)
        count += 1
    else:
        dict[length] += 1

    if count == 2:
        break

if len(select) < 2:
    print(0)
else:
    a = select.pop()
    b = select.pop()
    print(a*b)

Solution (Python):
from collections import Counter

input()
a = sorted(filter(lambda x: x[1] > 1, Counter(map(int, input().split())).items()), reverse=True)
if a and a[0][1] >= 4:
    print(a[0][0]**2)
else:
    if len(a) < 2:
        print(0)
    else:
        print(a[0][0] * a[1][0])

Solution (Python):
from collections import Counter
from operator import itemgetter

N = int(input())
A = Counter(map(int,input().split()))
A1 = list(A.items())
A1 = sorted(A1,key=itemgetter(1),reverse = True)
A1 = sorted(A1,key=itemgetter(0),reverse = True)



B =[]
for i in range(len(A1)):
    if A1[i][1] > 3:
        B.append(A1[i][0])
        if len(B) == 1:
            break
C =[]
for i in range(len(A1)):
    if A1[i][1] > 1:
        C.append(A1[i][0])
        if len(C) == 2:
            break

if len(C) == 0:
    print(0)
elif len(B) !=0:
    print(max(B[0]*B[0],C[0]*C[1]))
else:
    print(C[0]*C[1])

Solution (Python):
N = int(input())
lst = [int(x) for x in input().split()]
dct = {}
for x in lst:
    n = dct.get(x, 0) + 1
    dct[x] = n

lst = []
for k, v in sorted(dct.items(), reverse=True):
    if v <= 1:
        continue
    lst.append(k)
    if len(lst) == 1 and v // 2 >= 2:
        lst.append(k)
    if len(lst) == 2:
        print(lst[0] * lst[1])
        exit()
print(0)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n = int(readline())
lst1 = list(map(int,readline().split()))
ans = []
lst1.sort()
i = 0
while True:
    if i >= n-1:
        break
    if lst1[i] == lst1[i+1]:
        ans.append(lst1[i])
        i += 1
    i += 1
if len(ans) < 2:
    print(0)
else:
    print(ans[-1]*ans[-2])

Solution (Python):
from collections import *
n=int(input())
c=Counter(map(int,input().split()))
x=y=0
for k,v in c.items():
    if v>=2 and k>y:
        if k>=x:
            if v>=4:
                x=y=k
            else:
                x,y=k,x
        else:
            y=k
print(x*y)

Solution (Python):
from collections import Counter
n = int(input())
a = Counter(map(int, input().split()))
c = []
for k,v in a.items():
    if v >= 2:
        c.append(k)
    if v >= 4:
        c.append(k)

c.sort()
c = c[::-1]
if len(c) < 2:
    print(0)
else:
    print(c[0] * c[1])

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

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

m=0
m2 = 0
flag = False
tmp=0
for idx in x:
    tmp=m
    if x[idx]>=2:
        m=max(m,idx)
        if m!=tmp:
            if x[idx]>=4:
                flag=True
            else:
                flag=False


for idx in x:
    if x[idx]>=2:
        if idx!=m:
            m2 = max(m2,idx)

if flag:
    ans = m**2
else:
    ans = m*m2
print(ans)

Solution (Python):
import collections
n = int(input())
a = list(map(int, input().split()))

rec_hen = 0

acc = collections.Counter(a)
ssa = sorted(acc.items(), key=lambda x: x, reverse=True)
for i, c in ssa:
  if c >= 4:
    if rec_hen != 0:
      print(rec_hen * i)
      exit(0)
    print(i * i)
    exit(0)
  if c >= 2:
    if rec_hen != 0:
      print(rec_hen * i)
      exit(0)
    rec_hen = i

print(0)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
list=[]
count=0
ans=1
a.sort(reverse=True)
for i in range(1,len(a)):
	if a[i]==a[i-1]:
		ans*=a[i]
		a[i]=0
		count+=1
	if count==2:
		break
else:
	ans=0
print(ans)

Solution (Python):
from collections import Counter

def solve(n, A):
    c = Counter(A)
    cands = sorted(filter(lambda kv: kv[1] >= 2, c.items()),  key=lambda kv: -kv[0])
    ret = 0
    if len(cands) >= 1 and cands[0][1] >= 4:
        ret = cands[0][0] * cands[0][0]
    elif len(cands) >= 2:
        ret = cands[0][0] * cands[1][0]
    return ret

_n = int(input())
_A = map(int, input().split())
print(solve(_n, _A))

Solution (Python):
n = int(input())

sList = sorted(list(map(int,input().split())),reverse=True)
res = []
acc = False
for i in range(n-1):
  if acc:
    acc = False
  else:
      if sList[i] == sList[i+1]:
        res.append(sList[i])
        acc = True
      if len(res) == 2:
        print(res[0]*res[1])
        exit(0)

print(0)

Solution (Python):
n = int(input())

sList = sorted(list(map(int,input().split())),reverse=True)
res = []
acc = False
for i in range(n-1):
  if acc:
    acc = False
  else:
      if sList[i] == sList[i+1]:
        res.append(sList[i])
        acc = True
      if len(res) == 2:
        print(res[0]*res[1])
        exit(0)

print(0)

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
B=sorted(A)[::-1]
cnt=1
a=0
C=[]
for i in B:
  if a==i:
    cnt+=1
    if cnt==2:
      cnt=0
      C.append(a)
    if len(C)==2:
      print(C[0]*C[1])
      exit()
  else:
    a=i
    cnt=1
print(0)

Solution (Python):
import math
import calendar
import fractions
import itertools

n = int(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)

Solution (Python):
N = int(input())
A = [int(x) for x in input().split()]
A = sorted(A, reverse=True)
ans1 = 0
ans2 = 0
index = N
for i in range(N-1):
    if A[i] == A[i + 1]:
        ans1 = A[i]
        index = i + 2
        break
for j in range(index, N - 1):
    if A[j] == A[j + 1]:
        ans2 = A[j]
        flag = 1
        break

print(ans1*ans2)

Solution (Python):

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

i = 0 
big = 0
small = 0
while True:
    
    if i+2 > n: break
    if a[-i-1] == a[-i-2]:
        if big == 0:
            big = a[-i-1]
            
        else:
            small = a[-i-1]
            
            break
        i += 2
    else: i += 1
    
print(big*small)

Solution (Python):
n = int(input())
a = list(map(int, input().split( )))
a.sort()

l1 = a[-1]
i=-2
try:
    while a[i]!=l1:
        l1 = a[i]
        i-=1
    i-=1
    l2 = a[i]
    i-=1
    while a[i]!=l2:
        l2 = a[i]
        i-=1
except:
    print(0)
    exit()
print(l1*l2)

Solution (Python):
n = int(input())
a = [int(x) for x in input().split()]
a.sort(reverse=True)
ans = [0, 0]
i = j = 0
while i + 1 < n:
    if a[i] == a[i+1]:
        ans[j] = a[i+1]
        j += 1
        i += 2
        if j == 2: break
    else: i += 1
print(int(ans[0]*ans[1]))

Solution (Python):
from collections import defaultdict
d = defaultdict(int)

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

for i in li:
  d[i] += 1

h = 0
w = 0

new = sorted(d)

for i in new:
  if 4 > d[i] >= 2:
    if h >= w:
      w = i
    else:
      h = i

  elif d[i] >= 4:
    w = i
    h = i
    
print(w * h)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))

a.sort(reverse = True)

width = 0
height = 0
cnt = 0
for i in range(n - 1):
    if a[i] == a[i + 1] and cnt == 0:
        width = a[i]
        cnt += 1
        del a[i + 1]
    elif a[i] == a[i + 1] and cnt == 1:
        height = a[i]
        break

print(width * height)

Solution (Python):
import sys
from collections import defaultdict

use_clipboard=True
bbn=1000000007
	


		
def main():
	n = int(input())
	al = list(map(int, input().split()))
	
	cc=defaultdict(lambda : 0)
	for v in al:
		cc[v] += 1
		
	ccl=[]
	for key in cc:
		ccl.append((key,cc[key]))
	ccl.sort(reverse=True)
	
	ma,mb=0,0
	for v,n in ccl:
		if ma == 0 and n >= 4:
			return v*v
		elif ma == 0 and n >= 2:
			ma = v
		elif n >= 2:
			return ma*v
	return 0
	
	

isTest=False

def pa(v):
	if isTest:
		print(v)
		
class input_clipboard:
	def __init__(self,s):
		self.input_l=s.splitlines()
		self.ii=0
		
	def input(self):
		ret = self.input_l[self.ii]
		self.ii+=1
		return ret

if __name__ == "__main__":
	if sys.platform =='ios':
		if use_clipboard:
			import clipboard
			input_text=clipboard.get()
			ic=input_clipboard(input_text)
			input = lambda : ic.input()
		else:
			sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		
			
	ret = main()
	if ret is not None:
		print(ret)

Solution (Python):
n = int(input())
als = list(map(int,input().split()))
a1 = 0
a2 = 0
als.sort(reverse=1)

i = 0
while i < n-1:
    
    if als[i] == als[i+1] and a1 == 0:
        a1 = als[i]
        i += 2
        continue
    if als[i] == als[i+1] and a1 != 0:
        a2 = als[i]
        break
    i += 1
print(a1*a2)

Solution (Python):
n = int(input())
l = list(map(int, input().split()))
c_dic={}
for i in l:
    if i in c_dic:
        c_dic[i]+=1
    else:
        c_dic[i]=1
c_l=[]
for i,j in c_dic.items():
    if j>=2:
        c_l.append(i)
    if j>=4:
        c_l.append(i)
c_l.sort(reverse=True)
if len(c_l)<2:
    print(0)
else:
    print(c_l[0]*c_l[1])

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
count = {}
for i in a:
  if i in count:
    count[i] += 1
  else:
    count[i] = 1
edges = []
for i,j in count.items():
  if j >= 2:
    edges.append(i)
  if j >= 4:
    edges.append(i)

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

Solution (Python):
import collections
import heapq
n = int(input())
p = list(map(int, input().split()))
c = collections.Counter(p)
cond = 0
h = []
for line, cnt in c.most_common():
  if(cnt >= 2):
    for _ in range(cnt // 2):
      heapq.heappush(h, int(-1*line))
if(len(h) < 2):
  print(0)
  exit()
print(heapq.heappop(h) * heapq.heappop(h))

Solution (Python):
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
c = Counter(a)
x = []
y = []
for i in c:
    if c[i] > 3:
        y.append(i)
    if c[i] > 1:
        x.append(i)
x.sort()
y.sort()
ans1 = ans2 = 0
if len(x) > 1:
    ans1 = x[-1]*x[-2]
if len(y) > 0:
    ans2 = y[-1]**2
print(max(ans1, ans2))

Solution (Python):
D = {}
N = int(input())
A = list(map(int, input().split()))
Rec = []
Sq = []
for i in A:
  if i in D:
    D[i] += 1
  else:
    D[i] = 1
for i in D:
  if D[i] >= 4:
    Sq.append(i)
  if D[i] >= 2:
    Rec.append(i)
Rec.sort(reverse=True)
if len(Rec) <= 1 and len(Sq) == 0:
  print(0)
elif len(Sq) != 0 and len(Rec) >= 2:
  print(max(Rec[0] * Rec[1], max(Sq) * max(Sq)))
elif len(Sq) == 0 and len(Rec) >= 2:
  print(Rec[0] * Rec[1])

Solution (Python):
n=int(input())

a=sorted(list(map(int,input().split())),reverse=True)

stack=-1
t=[]
for i in a:
    if stack==i:
        t.append(i)
        stack=-1
    else:
        stack=i
    
    if len(t)>=2:
        break
try:
    print(t[0]*t[1])
except:
    print(0)

Solution (Python):

N=int(input())
A=list(map(int,input().split()))
A.sort(reverse=True)
ans=[]
l=0
while l<N-1:
    
    if A[l]==A[l+1]:
        ans.append(A[l])
        if len(ans)==2:
            break
        else:
            l+=2
    else:
        l+=1

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

Solution (Python):
import sys
import collections

input = sys.stdin.readline


def main():
    N = int(input())
    A = [int(x) for x in input().split()]

    C = collections.Counter(A)

    B = []
    for k in C.keys():
        if C[k] >= 2:
            B.append(k)

    if len(B) == 0:
        print("0")
        return
    elif len(B) == 1:
        B.sort(reverse=True)
        if C[B[0]] <= 3:
            print("0")
        else:
            print(B[0] * B[0])
        return
    else:
        B.sort(reverse=True)
        if C[B[0]] <= 3:
            print(B[0] * B[1])
        else:
            print(B[0] * B[0])

        return






    
    

if __name__ == '__main__':
    main()

Solution (Python):
import collections
N = int(input())
A = list(map(int, input().split()))
edge = collections.Counter(A)
a = 0
b = 0
c = 0
for i in sorted(edge.items()):
    if i[1] >= 2:
        if i[0] > a:
            b = a
            a = i[0]
    if i[1] >= 4:
        c = i[0]

if a * b >= c * c:
    answer = a * b
else:
    answer = c * c

print(answer)

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

cnt = {}

for a in A:
    cnt.setdefault(a, 0)
    cnt[a] += 1

cnt_filter = list(filter(lambda x: x[1] >= 2, cnt.items()))
cnt_filter.sort(key=lambda x: x[0], reverse=True)

x = 0
y = 0

if len(cnt_filter) >= 2:
    x = cnt_filter[0][0]
    y = cnt_filter[1][0]
    if cnt_filter[0][1] >= 4:
        y = x

ans = x * y

print(ans)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))

from collections import Counter
a=Counter(a)
a=sorted(a.items(), reverse=True)

x=0
y=0

for p,q in a:
  if q>=4:
    if x==0:
      x=y=p
      break
    else:
      y=p
      break
  elif q>=2:
    if x==0:
      x=p
    else:
      y=p
      break
print(x*y)

Solution (Python):
from collections import defaultdict
n = int(input())

d = defaultdict(int)
nums = []
for num in input().split():
    num = int(num)
    d[num] += 1
    
    if d[num] == 2:
        d.pop(num)
        nums.append(num)

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

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
A.sort()
l = 0
m = 0
while len(A) >= 2:
    a = A.pop()
    b = A.pop()
    if a == b:
        if l == 0:
            l = a
        elif m == 0:
            m = a
    else:
        A.append(b)
print(l * m)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
dic = {}
for i in a:
  if i in dic:
    dic[i] += 1
  else:
    dic[i] = 1
    
first = 0
second = 0
for i,j in dic.items():
  if j >= 2:
    if i > first :
      second = first
      first = i
    elif i > second:
      second = i
      
  if j >= 4:
    if i > first :
      second = first
      first = i
    elif i > second:
      second = i
  
print(first*second)

Solution (Python):
from collections import defaultdict

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

d = defaultdict(int)
for i in range(N):
    d[An[i]] += 1

edges = sorted(d.items(), key=lambda x: x[0], reverse=True)
w, h = 0, 0
ans = 0
for edge, amount in edges:
    if amount < 2:
        continue

    if amount >= 4:
        w, h = max(w, edge), max(h, edge)
        ans = max(ans, w*h)
    if amount >= 2:
        if not w:
            w = edge
        else:
            h = edge
            ans = max(ans, w*h)

print(ans)

Solution (Python):
N = int(input())
A = [int(i) for i in input().split()]
A.sort()
ans = 0
import collections
from collections import deque
d1 = deque()
count = 0
for i in range(N-1) :
    if A[i] == A[i+1] :
        count += 1
    else :
        if count == 0 :
            count = 0
            continue
        elif count < 3 :
            d1.append(A[i])
        else :
            d1.append(A[i])
            d1.append(A[i])
        count = 0
    if i == N-2 :
        if 0 < count < 3 :
            d1.append(A[i])
        elif count >= 3 :
            d1.append(A[i])
            d1.append(A[i])
if len(d1) < 2 :
    print(ans)
else :
    print(d1[-1] * d1[-2])

Solution (Python):
from collections import Counter
N = input()
A = list(map(int, input().split()))
C = Counter(A)
M = [0, 0]
for k, v in C.items():
    if v < 2: continue
    M.append(k)
    if v >= 4:
        M.append(k)
    M.sort(reverse=True)
    M = M[:2]
print(M[0]*M[1])

Solution (Python):
import collections
N=int(input())
L=list(map(int,input().split()))
ANS=[0,0]
c = collections.Counter(L).most_common()
    
for k,v in c:
  if v <= 1:
    break
  if v >= 4:
    ANS.append(k)
    ANS.append(k)
  else:
    ANS.append(k)

Z=sorted(ANS)
print(Z[-1]*Z[-2])

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
d={}
x=[0,0]
for i in range(n):
    try:
        d[a[i]]+=1
        if d[a[i]]==2 or d[a[i]]==4:
            x.append(a[i])
    except:
        d[a[i]]=1


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

Solution (Python):

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

from collections import Counter

ans = []

for (key, value) in Counter(A).items():
  if value >=2:
    ans.append(key)
  if value >= 4:
    ans.append(key)

if len(ans) <= 1:
  print(0)
else:
  ans = sorted(ans, reverse=True)
  print(ans[0] * ans[1])

Solution (Python):
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)

Solution (Python):
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
count = Counter(A)
A = sorted(list(set(A)),reverse = True)
a,b = 0,0
for i in A:
    if a == 0:
        if count[i] >= 4:
            a,b = i,i
            break
        elif count[i] >= 2:
            a = i
    else:
        if count[i] >= 2:
            b = i
            break
print(a*b)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()
A.sort(reverse=True)
A = Counter(A)
ans = 1
for k in sorted(A, reverse=True):
	if A[k] >= 4:
		if ans == 1:
			ans = k**2
			break
		else:
			ans *= k
			break
	elif  A[k] >= 2:
		if ans == 1:
			ans *= k
		else:
			ans *= k
			break
else:
	ans = 0
print(ans)

Solution (Python):
N = int(input())
A = [int(x) for x in input().split()]
A.sort(reverse = True)
HW = []
i = 1
while i<N:
  if A[i]==A[i-1]:
    n = A.count(A[i])
    HW += [A[i]]*(min(n//2,2))
    i = i + n -1
  else:
    i = i + 1
  if len(HW)>=2:
    break
if len(HW)<2:
  print(0)
else:
  print(HW[0]*HW[1])

Solution (Python):
n = int(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)

Solution (Python):
from collections import Counter

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

bar = []
for k, v in A.items():
  bar += [k]*(v//2)
bar.sort(reverse=True)  

if len(bar) < 2:
  print(0)
else:
  print(bar[0]*bar[1])

Solution (Python):
import collections
N = int(input())
A = list(map(int,input().split()))
c = collections.Counter(A)
As = list(set(A))
As.sort(reverse=True)
h1 = 0
h2 = 0
for i in range(len(As)):
    if c[As[i]] >= 4:
        if h1 == 0:
            h1 = As[i]
        h2 = As[i]
    elif c[As[i]] >= 2:
        if h1 == 0:
            h1 = As[i]
        else: h2 = As[i]
    if h1*h2 > 0:
        break
print(h1*h2)

Solution (Python):
n = int(input())
a = [int(i) for i in input().split()]
a.sort(reverse=True)
target = a[0]
cnt = 1
hen = []


for i in range(1,n):
    if target == a[i]:
        cnt += 1
        if cnt == 2:
            hen.append(a[i])
            cnt = 0
    else:
        target = a[i]
        cnt = 1
    
    if len(hen) == 2:
        print(hen[0]*hen[1])
        exit()

print(0)

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def main():
    N = I()
    A = LI()
    d = collections.OrderedDict()
    A = sorted(A)[::-1]
    for a in A:
        if not a in d:
            d[a] = 1
        else:
            d[a] += 1
    l_num = -1
    ans = 0
    for num, freq in d.items():
        if freq < 2:
            continue
        else:
            if l_num == -1:
                l_num = num
            else:
                ans = l_num * num
                break
        if freq >= 4:
            ans = num * num
            break
    print(ans)
main()

Solution (Python):
N=int(input())
A=list(map(int, input().split()))
A.sort()
tmp=[]
i=N-1
while i>0:
  if A[i]==A[i-1]:
    tmp.append(A[i])
    i-=2
  else:
    i-=1
if len(tmp)>=2:
  print(tmp[0]*tmp[1])
else:
  print(0)

Solution (Python):
from collections import *
n = int(input())
a = list(map(int, input().split()))
x = Counter(a)
if len(x) == 1:
    print(x[0][1]**2)
    exit()
d2 = deque()
d4 = deque()
for i in x.most_common():
    if i[1] > 3:
        d2.append(i[0])
        d4.append(i[0])
    elif i[1] > 1:
        d2.append(i[0])
    else:
        break
D2 = sorted(list(d2))
D4 = sorted(list(d4))
ans = 0
if len(D2) > 1:
    ans = D2[-1] * D2[-2]
if len(D4) > 0:
    ans = max(ans, D4[-1]**2)
print(ans)

Solution (Python):
import collections

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

C = collections.Counter(A)

num = []
num2 = []
for k,v in C.items():
    if (v>=2):
        num.append(k)
    if (v>=4):
        num2.append(k)

num.sort(reverse=True)
num2.sort(reverse=True)
if (len(num) >= 2 and len(num2) >= 1):
    print(max(num[0]*num[1],num2[0]**2))
elif (len(num) >= 2):
    print(num[0]*num[1])
else:
    print(0)

Solution (Python):
n = int(input())
*a, = sorted(map(int, input().split()))

r = [0, 0]

_a = a[0]
for i in range(1, n):
    if _a == a[i]:
        r.append(a[i])
        _a = -1
    else:
        _a = a[i]

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