exceptionhandling
Problem Statement
You are given a sequence of length N: A1, A2, ..., AN.
For each integer i between 1 and N (inclusive), answer the following question:
- Find the maximum value among the N-1 elements other than Ai in the sequence.
Constraints
- 2 ≤ N ≤ 200000
- 1 ≤ Ai ≤ 200000
- All values in input are integers.
Partial Scores
- In the test set worth 35 points, N ≦ 2000.
Input
Input is given from Standard Input in the following format:
N
A1
:
AN
Output
Print N lines. The i-th line (1 ≤ i ≤ N) should contain the maximum value among the N-1 elements other than Ai 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 A1, that is, A2 = 4 and A3 = 3, is 4.
- The maximum value among the two elements other than A2, that is, A1 = 1 and A3 = 3, is 3.
- The maximum value among the two elements other than A3, that is, A1 = 1 and A2 = 4, is 4.
Sample Input 2
2
5
5
Sample Output 2
5
5