#abc134c. [abc134_c]Exception Handling

[abc134_c]Exception Handling

Problem Statement

You are given a sequence of length NN: A1,A2,...,ANA_1, A_2, ..., A_N. For each integer ii between 11 and NN (inclusive), answer the following question:

  • Find the maximum value among the N1N-1 elements other than AiA_i in the sequence.

Constraints

  • 2leqNleq2000002 \\leq N \\leq 200000
  • 1leqAileq2000001 \\leq A_i \\leq 200000
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN A1A_1 :: ANA_N

Output

Print NN lines. The ii-th line (1leqileqN1 \\leq i \\leq N) should contain the maximum value among the N1N-1 elements other than AiA_i in the sequence.


Sample Input 1

3
1
4
3

Sample Output 1

4
3
4
  • The maximum value among the two elements other than A1A_1, that is, A2=4A_2 = 4 and A3=3A_3 = 3, is 44.
  • The maximum value among the two elements other than A2A_2, that is, A1=1A_1 = 1 and A3=3A_3 = 3, is 33.
  • The maximum value among the two elements other than A3A_3, that is, A1=1A_1 = 1 and A2=4A_2 = 4, is 44.

Sample Input 2

2
5
5

Sample Output 2

5
5