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

x = 0
y = 0
S = []

for a in A:
    if a in S:
        if a < x:
            continue
        elif a > y:
            x = y
            y = a
        else:
            x = a
        S.remove(a)
    else:
        S.append(a)

print(x*y)


Fixed submission:
N = int(input())
A = list(map(int, input().split(' ')))

x = 0
y = 0
S = set()

for a in A:
    if a in S:
        if a < x:
            continue
        elif a > y:
            x = y
            y = a
        else:
            x = a
        S.remove(a)
    else:
        S.add(a)

print(x*y)

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


B = sorted(list(set(A)), reverse=True)

for i in range(len(B)):
    b = B[i]
    n = A.count(b)
    if n >= 2:
        if n >= 4:
            print(b*b)
            exit()
        else:
            C = B[i+1:]
            for c in C:
                if  A.count(c) >= 2:
                    print(b*c)
                    exit()

print(0)


Fixed submission:
N = int(input())
A = list(map(int, input().split(' ')))

x = 0
y = 0
S = set()

for a in A:
    if a in S:
        if a < x:
            continue
        elif a > y:
            x = y
            y = a
        else:
            x = a
        S.remove(a)
    else:
        S.add(a)

print(x*y)

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


B = sorted(list(set(A)), reverse=True)

for i in range(len(B)):
    b = B[i]
    n = A.count(b)
    if n >= 2:
        if n >= 4:
            print(b*b)
            exit()
        elif:
            C = B[i+1:]
            for c in C:
                if  A.count(c) >= 2:
                    print(b*c)
                    exit()

print(0)


Fixed submission:
N = int(input())
A = list(map(int, input().split(' ')))

x = 0
y = 0
S = set()

for a in A:
    if a in S:
        if a < x:
            continue
        elif a > y:
            x = y
            y = a
        else:
            x = a
        S.remove(a)
    else:
        S.add(a)

print(x*y)

Buggy python submission (verdict: Runtime Error):
    N = int(input())
    A = list(map(int, input().split(' ')))
     
    B = []
    C = []
    D = []
     
    for a in A:
        if a in B:
            C[B.index(a)] += 1
        else:
            B.append(a)
            C.append(1)
     
    I = len(B)
     
    for i in range(I):
        D.append([B[i], C[i]])
     
    D = sorted(D, reverse=True)
     
    i = 0
    while i < I:
        x = D[i][0]
        d = D[i][1]
        if d > 1:
            if d > 3:
                print(x**2)
                exit()
            else:
                while i < I:
                    i += 1
                    y = D[i][0]
                    d = D[i][1]
                    if d > 1:
                        print(x*y)
                        exit()
        else:
            i += 1
     
    print(0)

Fixed submission:
N = int(input())
A = list(map(int, input().split(' ')))

x = 0
y = 0
S = set()

for a in A:
    if a in S:
        if a < x:
            continue
        elif a > y:
            x = y
            y = a
        else:
            x = a
        S.remove(a)
    else:
        S.add(a)

print(x*y)

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


B = list(set(A))          

while B:                  
    b = max(B)            
    if A.count(b) >= 4:   
        print(b**2)       
        exit()            
    elif A.count(b) >=2:  
        B.remove(b)       
        while B:          
            c = max(B)    
            if  A.count(c) >= 2:                    
                print(b*c)                          
                exit()    
            else:         
                B.remove(c)                         
    else:                 
        B.remove(b)       

print(0)   

Fixed submission:
N = int(input())
A = list(map(int, input().split(' ')))

x = 0
y = 0
S = set()

for a in A:
    if a in S:
        if a < x:
            continue
        elif a > y:
            x = y
            y = a
        else:
            x = a
        S.remove(a)
    else:
        S.add(a)

print(x*y)

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


B = list(set(A))

while B:
    b = max(B)
    if A.count(b) >= 4:
        print(b**2)
        exit()
    elif A.count(b) >=2:
        B.remove(b)
        while B:
            c = max(B)
            if  A.count(c) >= 2:
                print(b*c)
                exit()
            else:
                B.remove(c)
    else:
        B.remove(c)

print(0)


Fixed submission:
N = int(input())
A = list(map(int, input().split(' ')))

x = 0
y = 0
S = set()

for a in A:
    if a in S:
        if a < x:
            continue
        elif a > y:
            x = y
            y = a
        else:
            x = a
        S.remove(a)
    else:
        S.add(a)

print(x*y)

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


while not len(A) == 0:
    a = max(A)
    if A.count(a) >= 4:
        print(a**2)
        exit()
    elif A.count(a) >=2:
        while a in A:A.remove(a)
        while not len(A) == 0:
            a2 = max(A)
            if  A.count(a2) >= 2:
                print(a*a2)
                exit()
            else:
                while a2 in A:A.remove(a)
    else:
        while a in A:A.remove(a)

print(0)


Fixed submission:
N = int(input())
A = list(map(int, input().split(' ')))

x = 0
y = 0
S = set()

for a in A:
    if a in S:
        if a < x:
            continue
        elif a > y:
            x = y
            y = a
        else:
            x = a
        S.remove(a)
    else:
        S.add(a)

print(x*y)

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


B = sorted(list(set(A)), reverse=True)

for i in range(len(B)):
    b = B[i]
    if A.count(b) >= 4:
        print(b**2)
        exit()
    elif A.count(b) >=2:
        C = B[i+1:]
        for c in C:
            if  A.count(c) >= 2:
                print(b*c)
                exit()

print(0)


Fixed submission:
N = int(input())
A = list(map(int, input().split(' ')))

x = 0
y = 0
S = set()

for a in A:
    if a in S:
        if a < x:
            continue
        elif a > y:
            x = y
            y = a
        else:
            x = a
        S.remove(a)
    else:
        S.add(a)

print(x*y)