Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
X = list(set(A))

d = {}
for x in X:
  num = A.count(x)
  d[x] = num
result = []
for k, v in d.items():
  if(v >= 4):
    result.append(k)
    result.append(k)
  elif(v >= 2):
    result.append(k)
result.sort()
print(result[-1] * result[-2])


Fixed submission:
N = int(input())
A = list(map(int,input().split()))
d = {}
for a in A:
  if(a in d):
    d[a] += 1
  else:
    d[a] = 1
x, y = 0, 0
for k, v in d.items():
  if(v >= 2 and k > y):
    if(k >= x):
      if(v >= 4):
        y = k
      else:
        y = x
      x = k
    else:
      y = k
print(x * y)

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

two = [0]*N
four = [0]*N 
for x in list(set(A)):
  num = A.count(x)
  if(num >= 4):
    four[x] = x
  elif(num != 1):
    two[x] = x
two.sort()
four.sort()
print(max(four[-1]**2, two[-1]*two[-2]))


Fixed submission:
N = int(input())
A = list(map(int,input().split()))
d = {}
for a in A:
  if(a in d):
    d[a] += 1
  else:
    d[a] = 1
x, y = 0, 0
for k, v in d.items():
  if(v >= 2 and k > y):
    if(k >= x):
      if(v >= 4):
        y = k
      else:
        y = x
      x = k
    else:
      y = k
print(x * y)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))

c = {a: A.count(a) for a in A if A.count(a) >= 2}
cc = sorted(c)
x = len(c)
if(x <= 1):
  ans = 0
elif(c.get(cc[x-1]) >= 4):
  ans = cc[x-1] * cc[x-1]
else:
  ans = cc[x-1] * cc[x-2]
print(ans)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
d = {}
for a in A:
  if(a in d):
    d[a] += 1
  else:
    d[a] = 1
x, y = 0, 0
for k, v in d.items():
  if(v >= 2 and k > y):
    if(k >= x):
      if(v >= 4):
        y = k
      else:
        y = x
      x = k
    else:
      y = k
print(x * y)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))

c = {a: A.count(a) for a in A if A.count(a) >= 2}
cc = sorted(c)
x = len(c)
if(x <= 1):
  ans = 0
elif(c.get(cc[x-1]) >= 4):
  ans = cc[x-1] * cc[x-1]
else:
  ans = cc[x-1] * cc[x-2]
print(ans)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
d = {}
for a in A:
  if(a in d):
    d[a] += 1
  else:
    d[a] = 1
x, y = 0, 0
for k, v in d.items():
  if(v >= 2 and k > y):
    if(k >= x):
      if(v >= 4):
        y = k
      else:
        y = x
      x = k
    else:
      y = k
print(x * y)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))

d = {aa: 0 for aa in A}
c = sorted({a: A.count(a) for a in A if A.count(a) >= 2})
x = len(c)
if(x <= 1):
  ans = 0
elif(d.get(c[x-1]) >= 4):
  ans = c[x-1] * c[x-1]
else:
  ans = c[x-1] * c[x-2]
print(ans)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
d = {}
for a in A:
  if(a in d):
    d[a] += 1
  else:
    d[a] = 1
x, y = 0, 0
for k, v in d.items():
  if(v >= 2 and k > y):
    if(k >= x):
      if(v >= 4):
        y = k
      else:
        y = x
      x = k
    else:
      y = k
print(x * y)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))

d = {aa: A.count(aa) for aa in A}
c = sorted({k: v for k, v in d.items() if v >= 2})
x = len(c)
if(x <= 1):
  ans = 0
elif(d.get(c[x-1]) >= 4):
  ans = c[x-1] * c[x-1]
else:
  ans = c[x-1] * c[x-2]
print(ans)


Fixed submission:
N = int(input())
A = list(map(int,input().split()))
d = {}
for a in A:
  if(a in d):
    d[a] += 1
  else:
    d[a] = 1
x, y = 0, 0
for k, v in d.items():
  if(v >= 2 and k > y):
    if(k >= x):
      if(v >= 4):
        y = k
      else:
        y = x
      x = k
    else:
      y = k
print(x * y)