Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = [int(input()) for i in range(N)]
A = max(a)
b = sorted(a)[-2]
if a.count(A) > 1:
    for i in range(len(a)):
        print(A)
else:
    for i in range(len(a)):
        if i == a.index(A):
            print(b)
        else:
            print(A)

Fixed submission:
N = int(input())
a = [int(input()) for i in range(N)]
A = max(a)
b = sorted(a)[-2]
if a.count(A) > 1:
    for i in range(len(a)):
        print(A)
else:
    for i in range(len(a)):
        if a[i] == A:
            print(b)
        else:
            print(A)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = [int(input()) for i in range(N)]
A = max(a)
if a.count(A) > 1:
    for i in range(len(a)):
        print(A)
else:
    for i in range(len(a)):
        if i == a.index(A):
            print(sorted(a)[-2])
        else:
            print(A)

Fixed submission:
N = int(input())
a = [int(input()) for i in range(N)]
A = max(a)
b = sorted(a)[-2]
if a.count(A) > 1:
    for i in range(len(a)):
        print(A)
else:
    for i in range(len(a)):
        if a[i] == A:
            print(b)
        else:
            print(A)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = [int(input()) for i in range(N)]
A = max(a)
for i in range(len(a)):
    if i == a.index(A):
        print(sorted(a)[-2])
    else:
        print(A)

Fixed submission:
N = int(input())
a = [int(input()) for i in range(N)]
A = max(a)
b = sorted(a)[-2]
if a.count(A) > 1:
    for i in range(len(a)):
        print(A)
else:
    for i in range(len(a)):
        if a[i] == A:
            print(b)
        else:
            print(A)

Buggy python submission (verdict: Runtime Error):
N = int(input())
a = [int(input()) for i in range(N)]
A = max(a)
for i in range(len(a)):
    if i == a.index(A):
        print(sorted(set(a))[-2])
    else:
        print(A)

Fixed submission:
N = int(input())
a = [int(input()) for i in range(N)]
A = max(a)
b = sorted(a)[-2]
if a.count(A) > 1:
    for i in range(len(a)):
        print(A)
else:
    for i in range(len(a)):
        if a[i] == A:
            print(b)
        else:
            print(A)

Buggy python submission (verdict: Time Limit Exceeded):
import copy
N = int(input())
a = [int(input()) for i in range(N)]
b = copy.deepcopy(a)
for i in range(len(b)):
    del b[i]
    print(max(b))
    b = copy.deepcopy(a)

Fixed submission:
N = int(input())
a = [int(input()) for i in range(N)]
A = max(a)
b = sorted(a)[-2]
if a.count(A) > 1:
    for i in range(len(a)):
        print(A)
else:
    for i in range(len(a)):
        if a[i] == A:
            print(b)
        else:
            print(A)

Buggy python submission (verdict: Runtime Error):
import copy
N = int(input())
a = [input() for i in range(N)]
b = copy.deepcopy(a)
for i in b:
    del b[i]
    print(max(b))
    b = copy.deepcopy(a)

Fixed submission:
N = int(input())
a = [int(input()) for i in range(N)]
A = max(a)
b = sorted(a)[-2]
if a.count(A) > 1:
    for i in range(len(a)):
        print(A)
else:
    for i in range(len(a)):
        if a[i] == A:
            print(b)
        else:
            print(A)

Buggy python submission (verdict: Time Limit Exceeded):
import copy
N = int(input())
a = [input() for i in range(N)]
b = copy.deepcopy(a)
for i in range(len(a)):
    del b[i]
    print(max(b))
    b = copy.deepcopy(a)

Fixed submission:
N = int(input())
a = [int(input()) for i in range(N)]
A = max(a)
b = sorted(a)[-2]
if a.count(A) > 1:
    for i in range(len(a)):
        print(A)
else:
    for i in range(len(a)):
        if a[i] == A:
            print(b)
        else:
            print(A)

Buggy python submission (verdict: Time Limit Exceeded):
import copy
N = int(input())
a = [input() for i in range(N)]
b = copy.deepcopy(a)
for i in range(len(a)):
    del b[i]
    print(max(b))
    b = copy.deepcopy(a)

Fixed submission:
N = int(input())
a = [int(input()) for i in range(N)]
A = max(a)
b = sorted(a)[-2]
if a.count(A) > 1:
    for i in range(len(a)):
        print(A)
else:
    for i in range(len(a)):
        if a[i] == A:
            print(b)
        else:
            print(A)