import numpy as np

N = int(input())
nums = np.array([int(input()) for _ in range(N)])

org_indices = np.ones(N, dtype=bool)
for i in range(N):
    indices = np.copy(org_indices)
    indices[i] = False
    print(np.amax(nums[indices]))