def main():
  N = int(input())

  max_left = [0] * N
  max_right = [0] * N

  ary = []

  for i in range(N):
    ary.append(int(input()))

  for i in range(0, N-1):
    max_left[i+1] = max(max_left[i], a[i])

  for i in range(N - 1, 0, -1):
    max_right[i-1] = max(max_right[i], ary[i])

  for i in range(N):
	v = max(max_left[i], max_right[i])
	print(v)

main()
