Buggy python submission (verdict: Runtime Error):
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
a_max = max(a)
ind_M = a.index(a_max)
oth = max(max(a[:ind_M]), max(a[ind_M+1:]))
for i in range(n):
    if i != ind_M:
        print(a_max)
    else:
        print(oth)

Fixed submission:
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
a_max = max(a)
ind_M = a.index(a_max)
tmpl = a
tmpl.pop(ind_M)
for i in range(n):
    if i != ind_M:
        print(a_max)
    else:
        print(max(tmpl))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
a_max = max(a)
print(max(a[1:]))
for i in range(1, n-1):
    if a[i] != a_max:
        print(a_max)
    else:
        print(max(max(a[:i]), max(a[i+1:])))
print(max(a[:n-1]))
        

Fixed submission:
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
a_max = max(a)
ind_M = a.index(a_max)
tmpl = a
tmpl.pop(ind_M)
for i in range(n):
    if i != ind_M:
        print(a_max)
    else:
        print(max(tmpl))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
a_max = max(a)
print(max(a[1:]))
for i in range(1, n-1):
    if a[i] != a_max:
        print(a_max)
    else:
        print(max(max(a[:i]), max(a[i+1:])))
print(max(a[:n-1]))
        

Fixed submission:
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
a_max = max(a)
ind_M = a.index(a_max)
tmpl = a
tmpl.pop(ind_M)
for i in range(n):
    if i != ind_M:
        print(a_max)
    else:
        print(max(tmpl))

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
a_max = max(a)
for i in range(n):
    if a[i] == a_max:
        print(max(max(a[:i]), max(a[i+1:])))    
    else:
        print(a_max)

Fixed submission:
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
a_max = max(a)
ind_M = a.index(a_max)
tmpl = a
tmpl.pop(ind_M)
for i in range(n):
    if i != ind_M:
        print(a_max)
    else:
        print(max(tmpl))

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
a_max = max(a)
for i in range(n):
    if a[i] == a_max:
        a.pop(i)
        print(max(a))
    else:
        print(a_max)

Fixed submission:
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
a_max = max(a)
ind_M = a.index(a_max)
tmpl = a
tmpl.pop(ind_M)
for i in range(n):
    if i != ind_M:
        print(a_max)
    else:
        print(max(tmpl))

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):
    tmp = a.pop(0)
    print(max(a))
    a.append(tmp)
    

Fixed submission:
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
a_max = max(a)
ind_M = a.index(a_max)
tmpl = a
tmpl.pop(ind_M)
for i in range(n):
    if i != ind_M:
        print(a_max)
    else:
        print(max(tmpl))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(input()) for i in range(n)]
for i in range(n):
    tmp = a.pop(0)
    print(max(a))
    a.append(tmp)
    

Fixed submission:
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
a_max = max(a)
ind_M = a.index(a_max)
tmpl = a
tmpl.pop(ind_M)
for i in range(n):
    if i != ind_M:
        print(a_max)
    else:
        print(max(tmpl))