Buggy python submission (verdict: Runtime Error):
N = input()
A = list(map(int, input().split()))
A.sort(reverse=True)

now = A[0]
tateyoko = [0, 0]
count = 0
nowflag = False
for i in range(1, N):
  if (A[i] == now) and !nowflag:
    tateyoko[count] = now
    count += 1
    nowflag = True
  else:
    nowflag = False
  if count == 2:
    break
  now = A[i]
  
print(tateyoko[0] * tateyoko[1])

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
a.sort()
a.reverse()
max1=0;max2=0
count=0
for i in range(n-3):
  if a[i]==a[i+1]:
    max1=a[i]
    a[i+1]=0
    count=i+1
    break
if count==0:
  print(0)
  exit()
for j in range(count,n-1):
  if a[j]==a[j+1]:
    max2=a[j]
    break
print(max1*max2)

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a.sort()
a.reverse()
max1=0;max2=0
for i in range(n-3):
  if a[i]==a[i+1]:
    max1=a[i]
    a[i+1]=0
    count=i+1
    break
for j in range(count,n-1):
  if a[j]==a[j+1]:
    max2=a[j]
    break
print(max1*max2)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
a.sort()
a.reverse()
max1=0;max2=0
count=0
for i in range(n-3):
  if a[i]==a[i+1]:
    max1=a[i]
    a[i+1]=0
    count=i+1
    break
if count==0:
  print(0)
  exit()
for j in range(count,n-1):
  if a[j]==a[j+1]:
    max2=a[j]
    break
print(max1*max2)

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a.sort()
a.reverse()
max1=0;max2=0
for i in range(n-1):
  if a[i]==a[i+1]:
    max1=a[i]
    a[i+1]=0
    count=i
    break
for j in range(count,n-1):
  if a[j]==a[j+1]:
    max2=a[j]
    break
print(max1*max2)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
a.sort()
a.reverse()
max1=0;max2=0
count=0
for i in range(n-3):
  if a[i]==a[i+1]:
    max1=a[i]
    a[i+1]=0
    count=i+1
    break
if count==0:
  print(0)
  exit()
for j in range(count,n-1):
  if a[j]==a[j+1]:
    max2=a[j]
    break
print(max1*max2)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
b=[]
max1=0;max2=0
for i in range(n-1):
  for j in range(i+1,n):
    if a[i]==a[j]:
      if a[i]>max1:
        max2=max1
        max1=a[i]
      elif a[i]>max2:
        max2=a[i]
      a[j]=0
      break
print(max1*max2)


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
a.sort()
a.reverse()
max1=0;max2=0
count=0
for i in range(n-3):
  if a[i]==a[i+1]:
    max1=a[i]
    a[i+1]=0
    count=i+1
    break
if count==0:
  print(0)
  exit()
for j in range(count,n-1):
  if a[j]==a[j+1]:
    max2=a[j]
    break
print(max1*max2)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
b=[]
for i in range(n-1):
  for j in range(i+1,n):
    if a[i]==a[j]:
      b.append(a[i])
      a[j]=0
      break
if len(b)<=1:
  print(0)
else:
  b.sort()
  b.reverse()
  print(b[0]*b[1])

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
a.sort()
a.reverse()
max1=0;max2=0
count=0
for i in range(n-3):
  if a[i]==a[i+1]:
    max1=a[i]
    a[i+1]=0
    count=i+1
    break
if count==0:
  print(0)
  exit()
for j in range(count,n-1):
  if a[j]==a[j+1]:
    max2=a[j]
    break
print(max1*max2)