Buggy python submission (verdict: Runtime Error):
import numpy as np

N = int(input())

a = []
for i in range(N):
    a.append(int(input()))

if(N==1):
    print(a[0])
else:
    a_max = 0
    n_a_max = 0
    all_max = max(a)
    max_arg = np.argmax(a)

    if(max_arg!=0):
        a_max = max(a[:max_arg])
    if(max_arg!=N-1):
        n_a_max = max(a[max_arg+1:])

    if(a_max>=n_a_max):
        next_max = a_max
    else:
        next_max = n_a_max

    for i in range(N):
        if a[i]==all_max:
            print(next_max)
        else:
            print(all_max)
        

Fixed submission:
import numpy as np

N = int(input())

a = []
for i in range(N):
    a.append(int(input()))

if(N==1):
    print(a[0])
else:
    a_max = 0
    n_a_max = 0
    all_max = max(a)
    max_arg = np.argmax(a)

    if(max_arg!=0):
        a_max = max(a[:max_arg])
    if(max_arg!=N-1):
        n_a_max = max(a[max_arg+1:])

    if(a_max>=n_a_max):
        next_max = a_max
    else:
        next_max = n_a_max

    for i in range(N):
        if a[i]==all_max:
            print(next_max)
        else:
            print(all_max)

Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())

a = []
for i in range(N):
    a.append(int(input()))
a_max = 0
n_a_max = 0
all_max = max(a)
max_arg = np.argmax(a)

if(max_arg!=0):
    a_max = max(a[:max_arg])
if(max_arg!=N-1):
    n_a_max = max(a[max_arg+1:])

if(a_max>=n_a_max):
    next_max = a_max
else:
    next_max = n_a_max

for i in range(N):
    if a[i]==all_max:
        print(next_max)
    else:
        print(all_max)
    

Fixed submission:
import numpy as np

N = int(input())

a = []
for i in range(N):
    a.append(int(input()))

if(N==1):
    print(a[0])
else:
    a_max = 0
    n_a_max = 0
    all_max = max(a)
    max_arg = np.argmax(a)

    if(max_arg!=0):
        a_max = max(a[:max_arg])
    if(max_arg!=N-1):
        n_a_max = max(a[max_arg+1:])

    if(a_max>=n_a_max):
        next_max = a_max
    else:
        next_max = n_a_max

    for i in range(N):
        if a[i]==all_max:
            print(next_max)
        else:
            print(all_max)

Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())

a = []
for i in range(N):
    a.append(int(input()))

all_max = max(a)
max_arg = np.argmax(a)

print(max(a[1:]))

for i in range(1,N-1):
    if i!=max_arg:
        print(all_max)
    else:
        a_max = max(a[:i])
        n_a_max = max(a[i+1:])
        if(a_max>=n_a_max):
            print(a_max)
        else:
            print(n_a_max)

print(max(a[:N-1]))
    

Fixed submission:
import numpy as np

N = int(input())

a = []
for i in range(N):
    a.append(int(input()))

if(N==1):
    print(a[0])
else:
    a_max = 0
    n_a_max = 0
    all_max = max(a)
    max_arg = np.argmax(a)

    if(max_arg!=0):
        a_max = max(a[:max_arg])
    if(max_arg!=N-1):
        n_a_max = max(a[max_arg+1:])

    if(a_max>=n_a_max):
        next_max = a_max
    else:
        next_max = n_a_max

    for i in range(N):
        if a[i]==all_max:
            print(next_max)
        else:
            print(all_max)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

a = []
for i in range(N):
    a.append(int(input()))
print(max(a[1:]))
for i in range(1,N-1):
    a_max = max(a[:i])
    n_a_max = max(a[i+1:])
    if(a_max>=n_a_max):
        print(a_max)
    else:
        print(n_a_max)
print(max(a[:N-1]))
    

Fixed submission:
import numpy as np

N = int(input())

a = []
for i in range(N):
    a.append(int(input()))

if(N==1):
    print(a[0])
else:
    a_max = 0
    n_a_max = 0
    all_max = max(a)
    max_arg = np.argmax(a)

    if(max_arg!=0):
        a_max = max(a[:max_arg])
    if(max_arg!=N-1):
        n_a_max = max(a[max_arg+1:])

    if(a_max>=n_a_max):
        next_max = a_max
    else:
        next_max = n_a_max

    for i in range(N):
        if a[i]==all_max:
            print(next_max)
        else:
            print(all_max)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

a = []
for i in range(N):
    a.append(int(input()))

for i in range(N):
    max = 0
    for j in range(N):
        if j!=i and max < a[j]:
            max = a[j]
    print(max)
        

Fixed submission:
import numpy as np

N = int(input())

a = []
for i in range(N):
    a.append(int(input()))

if(N==1):
    print(a[0])
else:
    a_max = 0
    n_a_max = 0
    all_max = max(a)
    max_arg = np.argmax(a)

    if(max_arg!=0):
        a_max = max(a[:max_arg])
    if(max_arg!=N-1):
        n_a_max = max(a[max_arg+1:])

    if(a_max>=n_a_max):
        next_max = a_max
    else:
        next_max = n_a_max

    for i in range(N):
        if a[i]==all_max:
            print(next_max)
        else:
            print(all_max)