Buggy python submission (verdict: Runtime Error):

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

B=copy.copy(S)
B.sort()
if N>2:
	C=int(B[N-1])
	D=int(B[N-2])
	for i in S:
		if int(i)>=C:
			print(D)
		else:
			print(C)

else:
	print(S[1])
	print(S[0])

Fixed submission:
import copy
N = int(input())
S = []
for i in range(N):
    S.append(int(input()))

B=copy.copy(S)
B.sort()
if N>2:
	C=int(B[N-1])
	D=int(B[N-2])
	for i in S:
		if int(i)>=C:
			print(D)
		else:
			print(C)

else:
	print(S[1])
	print(S[0])

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = []
for _ in range(N):
    S.append(input())  # S += [input()] とも書ける

B=S.copy()
B.sort()
if N!=2:
	C=int(B[N-1])
	D=int(B[N-2])
	for i in S:
		if int(i)>=C:
			print(D)
		else:
			print(C)

else:
	print(S[1])
	print(S[0])

Fixed submission:
import copy
N = int(input())
S = []
for i in range(N):
    S.append(int(input()))

B=copy.copy(S)
B.sort()
if N>2:
	C=int(B[N-1])
	D=int(B[N-2])
	for i in S:
		if int(i)>=C:
			print(D)
		else:
			print(C)

else:
	print(S[1])
	print(S[0])

Buggy python submission (verdict: Runtime Error):
N=int(input())
A=[]
for p in range(N):
	A+=[int(input())]
B=A.copy()
B.sort()
if N!=2:
	C=int(B[N-1])
	D=int(B[N-2])
	for i in A:
		if i==C:
			print(D)
		else:
			print(C)

else:
	print(A[1])
	print(A[0])

Fixed submission:
import copy
N = int(input())
S = []
for i in range(N):
    S.append(int(input()))

B=copy.copy(S)
B.sort()
if N>2:
	C=int(B[N-1])
	D=int(B[N-2])
	for i in S:
		if int(i)>=C:
			print(D)
		else:
			print(C)

else:
	print(S[1])
	print(S[0])

Buggy python submission (verdict: Runtime Error):
N=int(input())
A=[]
for n in range(N):
	A+=[int(input())]
B=A.copy()
B.sort()
if N!=2:
	C=int(B[N-1])
	D=int(B[N-2])
	for i in A:
		if i==C:
			print(D)
		else:
			print(C)

else:
	print(A[1])
	print(A[0])

Fixed submission:
import copy
N = int(input())
S = []
for i in range(N):
    S.append(int(input()))

B=copy.copy(S)
B.sort()
if N>2:
	C=int(B[N-1])
	D=int(B[N-2])
	for i in S:
		if int(i)>=C:
			print(D)
		else:
			print(C)

else:
	print(S[1])
	print(S[0])

Buggy python submission (verdict: Runtime Error):
N=int(input())
A=[]
for n in range(N):
	A+=[int(input())]
B=A.copy()
B.sort()
if N==2:
	C=int(B[-1])
	D=int(B[-2])
	for i in A:
		if i==D:
			print(C)
		else:
			print(D)

else:
	print(A[1])
	print(A[0])

Fixed submission:
import copy
N = int(input())
S = []
for i in range(N):
    S.append(int(input()))

B=copy.copy(S)
B.sort()
if N>2:
	C=int(B[N-1])
	D=int(B[N-2])
	for i in S:
		if int(i)>=C:
			print(D)
		else:
			print(C)

else:
	print(S[1])
	print(S[0])

Buggy python submission (verdict: Runtime Error):
N=int(input())
A=[]
for n in range(N):
	A.append(int(input()))
B=A.copy()
B.sort()
C=int(B[-1])
D=int(B[-2])
for i in range(N):
	if A[i]>D:
		print(D)
	else:
		print(C)


Fixed submission:
import copy
N = int(input())
S = []
for i in range(N):
    S.append(int(input()))

B=copy.copy(S)
B.sort()
if N>2:
	C=int(B[N-1])
	D=int(B[N-2])
	for i in S:
		if int(i)>=C:
			print(D)
		else:
			print(C)

else:
	print(S[1])
	print(S[0])

Buggy python submission (verdict: Runtime Error):
N=int(input())
A=[]
for n in range(N):
	A.append(int(input()))
B=A.copy()
B.sort()
C=B[N-1]
D=B[N-2]
for i in range(N):
	if A[i]>D:
		print(D)
	else:
		print(C)


Fixed submission:
import copy
N = int(input())
S = []
for i in range(N):
    S.append(int(input()))

B=copy.copy(S)
B.sort()
if N>2:
	C=int(B[N-1])
	D=int(B[N-2])
	for i in S:
		if int(i)>=C:
			print(D)
		else:
			print(C)

else:
	print(S[1])
	print(S[0])

Buggy python submission (verdict: Runtime Error):
N=int(input())
A=[]
for n in range(N):
	A.append(input())
B=A.copy()
B.sort()
C=B[N-1]
D=B[N-2]
for i in range(N):
	if A[i]>D:
		print(D)
	else:
		print(C)


Fixed submission:
import copy
N = int(input())
S = []
for i in range(N):
    S.append(int(input()))

B=copy.copy(S)
B.sort()
if N>2:
	C=int(B[N-1])
	D=int(B[N-2])
	for i in S:
		if int(i)>=C:
			print(D)
		else:
			print(C)

else:
	print(S[1])
	print(S[0])

Buggy python submission (verdict: Runtime Error):
N=int(input())
A=[]
for n in range(N):
	A.append(input())
B=A.copy()
B.sort()
C=B[N-1]
D=B[N-2]
for i in range(N):
	if A[i]==C:
		print(D)
	else:
		print(C)
	


Fixed submission:
import copy
N = int(input())
S = []
for i in range(N):
    S.append(int(input()))

B=copy.copy(S)
B.sort()
if N>2:
	C=int(B[N-1])
	D=int(B[N-2])
	for i in S:
		if int(i)>=C:
			print(D)
		else:
			print(C)

else:
	print(S[1])
	print(S[0])