Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
A = list(int(input()) for i in range(N))
for i in range(N):
    p= A[i]

    M = max(A)
    del A[i]
    MM = max(A)
    if M == MM:
        print(M)
    else:
        print(MM)
    A.insert(i,p)

Fixed submission:
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
B= sorted(A)

for i in range(N):
    if A[i] == B[N-1]:
        ans = B[N-2]
        print(ans)
    else:
        print(B[N-1])

Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
A = list(int(input()) for i in range(N))
for i in range(N):
    p= A[i]

    M = max(A)
    del A[i]
    MM = max(A)
    if M == MM:
        print(M)
    else:
        print(MM)
    A.insert(i,p)

Fixed submission:
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
B= sorted(A)

for i in range(N):
    if A[i] == B[N-1]:
        ans = B[N-2]
        print(ans)
    else:
        print(B[N-1])

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
A = list(int(input()) for i in range(N))
for i in range(N):
    p= A[i]

    M = max(A)
    del A[i]
    MM = max(A)
    if M == MM:
        print(M)
    else:
        print(MM)
    A.insert(i,p)

Fixed submission:
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
B= sorted(A)

for i in range(N):
    if A[i] == B[N-1]:
        ans = B[N-2]
        print(ans)
    else:
        print(B[N-1])

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(int(input()) for i in range(N))
ans = A[0]
for i in range(N):
    stor = A.pop(i)
    for n in range(N-1):
        if ans < A[i]:
            ans = A[i]
    A.insert(i,stor)
    print(ans)
    ans = A[0]

Fixed submission:
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
B= sorted(A)

for i in range(N):
    if A[i] == B[N-1]:
        ans = B[N-2]
        print(ans)
    else:
        print(B[N-1])

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(int(input()) for i in range(N))
ans = A[0]
for i in range(N):
    stor = A.pop(i)
    for n in range(N-1):
        if ans < A[i]:
            ans = A[i]
    A.append(stor)
    print(ans)
    ans = A[0]

Fixed submission:
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
B= sorted(A)

for i in range(N):
    if A[i] == B[N-1]:
        ans = B[N-2]
        print(ans)
    else:
        print(B[N-1])

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(int(input()) for i in range(N))
ans = A[0]
for i in range(N):
    stor = A.pop(i)
    for n in range(N-1):
        if ans < A[i]:
            ans = A[i]
   A.append(stor)
    print(ans)
    ans = A[0]
        

Fixed submission:
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
B= sorted(A)

for i in range(N):
    if A[i] == B[N-1]:
        ans = B[N-2]
        print(ans)
    else:
        print(B[N-1])

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split))
ans = A[0]
for i in range(N):
    for n in range(i):
        if ans < A[i]:
            ans = A[i]
    for n in range(i+1,N):
        if ans < A[i]:
            ans = A[i]
    print(ans)
    ans = A[0]

Fixed submission:
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
B= sorted(A)

for i in range(N):
    if A[i] == B[N-1]:
        ans = B[N-2]
        print(ans)
    else:
        print(B[N-1])