N = input()[0]
A = input()[1:]

sorted_A = sorted(list(set(A)),reverse=True)

max_idx = [x == sorted_A[0] for x in A]

ans = [sorted_A[0]] * N
if max_idx.count(True) == 1: ans[A.index(sorted_A[0])] = sorted_A[1]
print(ans)