Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [input() for _ in range(N)]
tmp = 0
for i in range(N):
    if max(A) == A[i]:
        tmp = A.pop(i)
        print(max(A))
        A.insert(i,tmp)
    else:
        print(max(A))

Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]
if N == 2:
    for j in A[::-1]:
        print(j)
else:
    tmp = sorted(A)
    del tmp[0:(N-2)]
    for i in range(N):
        if A[i] == tmp[1]:
            print(tmp[0])
        else:
            print(tmp[1])

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [input() for _ in range(N)]
for i in range(N):
    if max(A) == A[i]:
        A.remove(A[i])
        print(max(A))
        A.insert(i,A[i])
    else:
        print(max(A))

Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]
if N == 2:
    for j in A[::-1]:
        print(j)
else:
    tmp = sorted(A)
    del tmp[0:(N-2)]
    for i in range(N):
        if A[i] == tmp[1]:
            print(tmp[0])
        else:
            print(tmp[1])

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [input() for _ in range(N)]
for j in range(N):
    if max(A) == A[i]:
        A.remove(A[i])
        print(max(A))
        A.insert(i,A[i])
    else:
        print(max(A))

Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]
if N == 2:
    for j in A[::-1]:
        print(j)
else:
    tmp = sorted(A)
    del tmp[0:(N-2)]
    for i in range(N):
        if A[i] == tmp[1]:
            print(tmp[0])
        else:
            print(tmp[1])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [input() for _ in range(N)]
tmp = 0
for j in range(N):
    tmp = A.pop(j)
    print(max(A))
    A.insert(j,tmp)


Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]
if N == 2:
    for j in A[::-1]:
        print(j)
else:
    tmp = sorted(A)
    del tmp[0:(N-2)]
    for i in range(N):
        if A[i] == tmp[1]:
            print(tmp[0])
        else:
            print(tmp[1])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [input() for _ in range(N)]
tmp = 0
for j in range(N):
    tmp = A.pop(j)
    print(max(A))
    A.insert(j,tmp)


Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]
if N == 2:
    for j in A[::-1]:
        print(j)
else:
    tmp = sorted(A)
    del tmp[0:(N-2)]
    for i in range(N):
        if A[i] == tmp[1]:
            print(tmp[0])
        else:
            print(tmp[1])

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = []
tmp = 0
for _ in range(N):
    A.append(int(input()))
    for j in range(N):
        tmp = A.pop(j)
        print(max(A))
        A.insert(j,tmp)


Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]
if N == 2:
    for j in A[::-1]:
        print(j)
else:
    tmp = sorted(A)
    del tmp[0:(N-2)]
    for i in range(N):
        if A[i] == tmp[1]:
            print(tmp[0])
        else:
            print(tmp[1])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = []
tmp = 0
for _ in range(N):
    A.append(int(input()))
for i in range(N):
    tmp = A.pop(i)
    print(max(A))
    A.insert(i,tmp)

Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]
if N == 2:
    for j in A[::-1]:
        print(j)
else:
    tmp = sorted(A)
    del tmp[0:(N-2)]
    for i in range(N):
        if A[i] == tmp[1]:
            print(tmp[0])
        else:
            print(tmp[1])