Buggy python submission (verdict: Runtime Error):
a = int(input())
ar = list(map(int,input().split(" ")))
ar = sorted(ar,reverse=True)
A = 0
B = 0
j = 0
while True:
    if A != 0 and B != 0:
        break
    if j == a - 1:
        break
    if ar[j] == ar[j+1] and A == 0:
        A = ar[j]
        j += 1
    elif ar[j] == ar[j+1] and A != 0:
        B = ar[j]
        j += 1
    j += 1
    print(ar[j])
print(A * B)

Fixed submission:
import collections
a = int(input())
ar = list(map(int,input().split(" ")))
br = collections.Counter(ar)
cr = []
for k,v in br.items():
    if v >= 4:
        cr.append(k)
        cr.append(k)
    elif v >= 2:
        cr.append(k)
cr = sorted(cr,reverse=True)
if len(cr) < 2:
    print(0)
else:
    print(cr[0] * cr[1])

Buggy python submission (verdict: Time Limit Exceeded):
a = int(input())
ar = list(map(int,input().split(" ")))
br = set(ar)
cr = []
for r in br:
    if ar.count(r) >= 4:
        cr.append(r)
        cr.append(r)
    elif ar.count(r) >= 2:
        cr.append(r)
cr = sorted(cr,reverse=True)
if len(cr) < 2:
    print(0)
else:
    print(cr[0] * cr[1])

Fixed submission:
import collections
a = int(input())
ar = list(map(int,input().split(" ")))
br = collections.Counter(ar)
cr = []
for k,v in br.items():
    if v >= 4:
        cr.append(k)
        cr.append(k)
    elif v >= 2:
        cr.append(k)
cr = sorted(cr,reverse=True)
if len(cr) < 2:
    print(0)
else:
    print(cr[0] * cr[1])

Buggy python submission (verdict: Time Limit Exceeded):
a = int(input())
ar = list(map(int,input().split(" ")))
br = set(ar)
cr = []
for r in br:
    if ar.count(r) >= 2:
        if ar.count(r) % 2 == 1:
            for i in range(ar.count(r) - 1):
                cr.append(r)
        else:
            for i in range(ar.count(r)):
                cr.append(r)
cr = sorted(cr,reverse=True)
if len(cr) < 4:
    print(0)
else:
    print(cr[0] * cr[2])

Fixed submission:
import collections
a = int(input())
ar = list(map(int,input().split(" ")))
br = collections.Counter(ar)
cr = []
for k,v in br.items():
    if v >= 4:
        cr.append(k)
        cr.append(k)
    elif v >= 2:
        cr.append(k)
cr = sorted(cr,reverse=True)
if len(cr) < 2:
    print(0)
else:
    print(cr[0] * cr[1])

Buggy python submission (verdict: Time Limit Exceeded):
a = int(input())
ar = list(map(int,input().split(" ")))
cr = set(ar)
dr = sorted(cr,reverse=True)
br = []
for r in dr:
    if len(br) >= 2:
        break
    if ar.count(r) >= 4:
        br.append(r)
        br.append(r)
    elif ar.count(r) >= 2:
        br.append(r)
if len(br) == 0:
    print(0)
else:
    print(br[0] * br[1])

Fixed submission:
import collections
a = int(input())
ar = list(map(int,input().split(" ")))
br = collections.Counter(ar)
cr = []
for k,v in br.items():
    if v >= 4:
        cr.append(k)
        cr.append(k)
    elif v >= 2:
        cr.append(k)
cr = sorted(cr,reverse=True)
if len(cr) < 2:
    print(0)
else:
    print(cr[0] * cr[1])

Buggy python submission (verdict: Time Limit Exceeded):
a = int(input())
ar = list(map(int,input().split(" ")))
cr = set(ar)
dr = sorted(cr,reverse=True)
br = []
for r in dr:
    if len(br) == 2:
        break
    if ar.count(r) >= 4:
        br.append(r)
        if len(br) == 2:
            break
        br.append(r)
    elif ar.count(r) >= 2:
        br.append(r)
if len(br) == 0:
    print(0)
else:
    print(br[0] * br[1])

Fixed submission:
import collections
a = int(input())
ar = list(map(int,input().split(" ")))
br = collections.Counter(ar)
cr = []
for k,v in br.items():
    if v >= 4:
        cr.append(k)
        cr.append(k)
    elif v >= 2:
        cr.append(k)
cr = sorted(cr,reverse=True)
if len(cr) < 2:
    print(0)
else:
    print(cr[0] * cr[1])

Buggy python submission (verdict: Time Limit Exceeded):
a = int(input())
ar = list(map(int,input().split(" ")))
br = []
for r in set(ar):
    if ar.count(r) >= 4:
        br.append(r)
        br.append(r)
    elif ar.count(r) >= 2:
        br.append(r)
br = sorted(br,reverse=True)
if len(br) == 0:
    print(0)
else:
    print(br[0] * br[1])

Fixed submission:
import collections
a = int(input())
ar = list(map(int,input().split(" ")))
br = collections.Counter(ar)
cr = []
for k,v in br.items():
    if v >= 4:
        cr.append(k)
        cr.append(k)
    elif v >= 2:
        cr.append(k)
cr = sorted(cr,reverse=True)
if len(cr) < 2:
    print(0)
else:
    print(cr[0] * cr[1])