Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = sorted([int(i) for i in input().split()])
for i in set(a):
  if a.count(i)== 1:
    a.remove(i)
if len(a) <= 3:
  print(0)
else:
  if a.count(max(a)) == 3:
    print(a[-1]*a[-4])
  else:
    print(a[-1]*a[-3])
  
    

Fixed submission:
import collections
N = int(input())
A = collections.Counter(list(map(int, input().split())))
seihou = []
tyouhou = []
ans = 0

for i in A.keys():
    if A[i] >= 2:
        tyouhou.append(i)
    if A[i] >= 4:
        seihou.append(i)

if len(seihou) >= 1:
    ans = max(seihou)**2

if len(tyouhou) >= 2:
    c = max(tyouhou)
    tyouhou.remove(c)
    ans = max(ans, c*max(tyouhou))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import collections
N = int(input())
A = collections.Counter(list(map(int, input().split())))
seihou = []
tyouhou = []
ans = 0

for i in A.keys():
    if A[i] >= 2:
        tyouhou = tyouhou+[i]
    if A[i] >= 4:
        seihou = seihou+[i]

if len(seihou) >= 1:
    ans = max(seihou)**2

if len(tyouhou) >= 2:
    c = max(tyouhou)
    tyouhou.remove(c)
    ans = max(ans, c*max(tyouhou))
print(ans)

Fixed submission:
import collections
N = int(input())
A = collections.Counter(list(map(int, input().split())))
seihou = []
tyouhou = []
ans = 0

for i in A.keys():
    if A[i] >= 2:
        tyouhou.append(i)
    if A[i] >= 4:
        seihou.append(i)

if len(seihou) >= 1:
    ans = max(seihou)**2

if len(tyouhou) >= 2:
    c = max(tyouhou)
    tyouhou.remove(c)
    ans = max(ans, c*max(tyouhou))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import collections
N = int(input())
A = collections.Counter(list(map(int, input().split())))
seihou = []
tyouhou = []
ans = 0

for i in A.keys():
    if A[i] >= 2:
        tyouhou = tyouhou+[i]
    if A[i] >= 4:
        seihou = seihou+[i]

if len(seihou) >= 1:
    ans = max(seihou)**2

if len(tyouhou) >= 2:
    tyouhou.sort()
    ans = max(ans, tyouhou[-1]*tyouhou[-2])
print(ans)

Fixed submission:
import collections
N = int(input())
A = collections.Counter(list(map(int, input().split())))
seihou = []
tyouhou = []
ans = 0

for i in A.keys():
    if A[i] >= 2:
        tyouhou.append(i)
    if A[i] >= 4:
        seihou.append(i)

if len(seihou) >= 1:
    ans = max(seihou)**2

if len(tyouhou) >= 2:
    c = max(tyouhou)
    tyouhou.remove(c)
    ans = max(ans, c*max(tyouhou))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
ans = 0
AA = [i for i in A if A.count(i)>=2]

AAA =sorted(set(AA))

#長方形を調べる
if len(AAA) >= 2:
    ans = AAA[-1]*AAA[-2]

#正方形を調べる
for i in AAA:
    if AA.count(i) >=4:
        ans =max(ans, i**2)
        
print(ans)

Fixed submission:
import collections
N = int(input())
A = collections.Counter(list(map(int, input().split())))
seihou = []
tyouhou = []
ans = 0

for i in A.keys():
    if A[i] >= 2:
        tyouhou.append(i)
    if A[i] >= 4:
        seihou.append(i)

if len(seihou) >= 1:
    ans = max(seihou)**2

if len(tyouhou) >= 2:
    c = max(tyouhou)
    tyouhou.remove(c)
    ans = max(ans, c*max(tyouhou))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = sorted(list(map(int, input().split())))
ans = 0
AA = [i for i in A if A.count(i)>=2]

AAA =sorted(set(AA))

#長方形を調べる
if len(AAA) >= 2:
    ans = AAA[-1]*AAA[-2]

#正方形を調べる
for i in AAA:
    if AA.count(i) >=4:
        ans =max(ans, i**2)
        
print(ans)

Fixed submission:
import collections
N = int(input())
A = collections.Counter(list(map(int, input().split())))
seihou = []
tyouhou = []
ans = 0

for i in A.keys():
    if A[i] >= 2:
        tyouhou.append(i)
    if A[i] >= 4:
        seihou.append(i)

if len(seihou) >= 1:
    ans = max(seihou)**2

if len(tyouhou) >= 2:
    c = max(tyouhou)
    tyouhou.remove(c)
    ans = max(ans, c*max(tyouhou))
print(ans)