Buggy python submission (verdict: Runtime Error):
n=int(input())
data=[int(aa) for aa in input().split()]
d=[0 for aa in range(100010+1)]
for aa in data:
    d[aa]+=1
#print(d)
mylist=[0,0]
ans1=0
for aa in range(100010+1):
    if d[aa] >3 and ans1 < aa:
        ans1=aa
    if d[aa] >1 :
        if aa not in mylist:
            mylist.pop(0)
            mylist.append(aa)
#            print(mylist)

print(max(ans1*ans1,mylist[0]*mylist[1]))

Fixed submission:
from collections import Counter
n=int(input())
data=[int(aa) for aa in input().split()]

dct=Counter(data)
dct=dct.items()

dct2=[item for item in dct if item[1] > 1]
dct2.sort(reverse=True)

dct4=[item for item in dct if item[1] > 3]
dct4.sort(reverse=True)

ans=0
if len(dct2) > 1:
  ans=dct2[0][0]*dct2[1][0]
if len(dct4) > 0: 
  ans=max(ans,dct4[0][0]*dct4[0][0])

print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input())
data=[int(aa) for aa in input().split()]
d=[0 for aa in range(100000+1)]
for aa in data:
    d[aa]+=1
#print(d)
mydata=0
mylist=[0,0]
for aa in range(100000+1):
    if d[aa] >3:
        mydata=aa
    if d[aa] >1 :
        if aa not in mylist:
            mylist.pop(0)
            mylist.append(aa)
#            print(mylist)
 
print(max(mydata*mydata,mylist[0]*mylist[1]))
n=int(input())
data=[int(aa) for aa in input().split()]
d=[0 for aa in range(100000+1)]
for aa in data:
    d[aa]+=1
#print(d)
mydata=0
mylist=[0,0]
for aa in range(100000+1):
    if d[aa] >3:
        mydata=aa
    if d[aa] >1 :
        if aa not in mylist:
            mylist.pop(0)
            mylist.append(aa)
#            print(mylist)

print(max(mydata*mydata,mylist[0]*mylist[1]))


Fixed submission:
from collections import Counter
n=int(input())
data=[int(aa) for aa in input().split()]

dct=Counter(data)
dct=dct.items()

dct2=[item for item in dct if item[1] > 1]
dct2.sort(reverse=True)

dct4=[item for item in dct if item[1] > 3]
dct4.sort(reverse=True)

ans=0
if len(dct2) > 1:
  ans=dct2[0][0]*dct2[1][0]
if len(dct4) > 0: 
  ans=max(ans,dct4[0][0]*dct4[0][0])

print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input())
data=[int(aa) for aa in input().split()]
d=[0 for aa in range(100000+1)]
for aa in data:
    d[aa]+=1
#print(d)
mydata=0
mylist=[0,0]
for aa in range(100000+1):
    if d[aa] >3:
        mydata=aa
    if d[aa] >1 :
        if aa not in mylist:
            mylist.pop(0)
            mylist.append(aa)
#            print(mylist)

print(max(mydata*mydata,mylist[0]*mylist[1]))


Fixed submission:
from collections import Counter
n=int(input())
data=[int(aa) for aa in input().split()]

dct=Counter(data)
dct=dct.items()

dct2=[item for item in dct if item[1] > 1]
dct2.sort(reverse=True)

dct4=[item for item in dct if item[1] > 3]
dct4.sort(reverse=True)

ans=0
if len(dct2) > 1:
  ans=dct2[0][0]*dct2[1][0]
if len(dct4) > 0: 
  ans=max(ans,dct4[0][0]*dct4[0][0])

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
data=[int(aa) for aa in input().split()]
data.sort()
#print(data)
mydata=0
mylist=[0,0]
for aa in data:
    if data.count(aa) >3:
        mydata=aa
    if data.count(aa) >1 :
        if aa not in mylist:
            mylist.pop(0)
            mylist.append(aa)
#            print(mylist)

print(max(mydata*mydata,mylist[0]*mylist[1]))


Fixed submission:
from collections import Counter
n=int(input())
data=[int(aa) for aa in input().split()]

dct=Counter(data)
dct=dct.items()

dct2=[item for item in dct if item[1] > 1]
dct2.sort(reverse=True)

dct4=[item for item in dct if item[1] > 3]
dct4.sort(reverse=True)

ans=0
if len(dct2) > 1:
  ans=dct2[0][0]*dct2[1][0]
if len(dct4) > 0: 
  ans=max(ans,dct4[0][0]*dct4[0][0])

print(ans)