Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int, input().split()))
A.sort()
hst = [0] * (max(A) + 1)
for a in A:
    hst[a] += 1

rec = []
squ = []
A_ = list(set(A))
for a in A_:
    if hst[a] > 1:
        rec.append(a)
    if hst[a] >= 4:
        squ.append(a)

# print(rec)
# print(squ)

s = 0
if len(squ) != 0:
    s = squ[-1]**2

if len(rec) < 2:
    print(s)
else:
    print(max(s, rec[-1]*rec[-2]))

Fixed submission:
from collections import Counter
n = int(input())
A = list(map(int, input().split()))

C = Counter(A)

rec = []
squ = []

for a in A:
    if 2 <= C[a]:
        rec.append(a)
    if 4 <= C[a]:
        squ.append(a)
rec = list(set(rec))
squ = list(set(squ))
# print(rec)
# print(squ)

s = 0
if len(squ) != 0:
    s = max(squ)**2

if len(rec) < 2:
    print(s)
else:
    rec.sort(reverse=True)
    print(max(s, rec[0]*rec[1]))

Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int, input().split()))
A.sort()
hst = [0] * (max(A) + 1)
for a in A:
    hst[a] += 1

rec = []
squ = []
for a in list(set(A)):
    if hst[a] > 1:
        rec.append(a)
    if hst[a] >= 4:
        squ.append(a)

# print(rec)
# print(squ)

s = 0
if len(squ) != 0:
    s = squ[-1]**2

if len(rec) < 2:
    print(s)
else:
    print(max(s, rec[-1]*rec[-2]))

Fixed submission:
from collections import Counter
n = int(input())
A = list(map(int, input().split()))

C = Counter(A)

rec = []
squ = []

for a in A:
    if 2 <= C[a]:
        rec.append(a)
    if 4 <= C[a]:
        squ.append(a)
rec = list(set(rec))
squ = list(set(squ))
# print(rec)
# print(squ)

s = 0
if len(squ) != 0:
    s = max(squ)**2

if len(rec) < 2:
    print(s)
else:
    rec.sort(reverse=True)
    print(max(s, rec[0]*rec[1]))

Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int, input().split()))
A.sort()
hst = [0] * (max(A) + 1)
for a in A:
    hst[a] += 1

rec = []
squ = []
for a in list(set(A)):
    if hst[a] > 1:
        rec.append(a)
    if hst[a] >= 4:
        squ.append(a)

# print(rec)
# print(squ)

s = 0
if len(squ) != 0:
    s = squ[-1]**2

if len(rec) < 2:
    print(s)
else:
    print(max(s, rec[-1]*rec[-2]))

Fixed submission:
from collections import Counter
n = int(input())
A = list(map(int, input().split()))

C = Counter(A)

rec = []
squ = []

for a in A:
    if 2 <= C[a]:
        rec.append(a)
    if 4 <= C[a]:
        squ.append(a)
rec = list(set(rec))
squ = list(set(squ))
# print(rec)
# print(squ)

s = 0
if len(squ) != 0:
    s = max(squ)**2

if len(rec) < 2:
    print(s)
else:
    rec.sort(reverse=True)
    print(max(s, rec[0]*rec[1]))

Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int, input().split()))
A.sort()
hst = [0] * (max(A) + 1)
for a in A:
    hst[a] += 1

rec = []
squ = []
for a in list(set(A)):
    if hst[a] > 1:
        rec.append(a)
    if hst[a] >= 4:
        squ.append(a)

# print(rec)
# print(squ)

s = 0
if len(squ) != 0:
    s = squ[-1]**2

if len(rec) < 2 and s == 0:
    print(0)
else:
    print(max(s, rec[-1]*rec[-2]))

Fixed submission:
from collections import Counter
n = int(input())
A = list(map(int, input().split()))

C = Counter(A)

rec = []
squ = []

for a in A:
    if 2 <= C[a]:
        rec.append(a)
    if 4 <= C[a]:
        squ.append(a)
rec = list(set(rec))
squ = list(set(squ))
# print(rec)
# print(squ)

s = 0
if len(squ) != 0:
    s = max(squ)**2

if len(rec) < 2:
    print(s)
else:
    rec.sort(reverse=True)
    print(max(s, rec[0]*rec[1]))

Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int, input().split()))
A.sort()
hst = [0] * (A[-1] + 1)
for a in A:
    hst[a] += 1

rec = []
squ = []
for a in list(set(A)):
    if hst[a] > 1:
        rec.append(a)
    if hst[a] >= 4:
        squ.append(a)

# print(rec)
# print(squ)

s = 0
if len(squ) != 0:
    s = squ[-1]**2

if len(rec) <= 1 and len(squ) < 1:
    print(0)
else:
    print(max(s, rec[-1]*rec[-2]))

Fixed submission:
from collections import Counter
n = int(input())
A = list(map(int, input().split()))

C = Counter(A)

rec = []
squ = []

for a in A:
    if 2 <= C[a]:
        rec.append(a)
    if 4 <= C[a]:
        squ.append(a)
rec = list(set(rec))
squ = list(set(squ))
# print(rec)
# print(squ)

s = 0
if len(squ) != 0:
    s = max(squ)**2

if len(rec) < 2:
    print(s)
else:
    rec.sort(reverse=True)
    print(max(s, rec[0]*rec[1]))