Problem Statement
In JOI City, there are $N$ residents numbered from $1$ to $N$, and the age of resident $i$ ($1 \le i \le N$) is $A_i$ years old.
The ages $A_1, A_2, \dots, A_N$ of the residents of JOI City are given. Write a program to find, for each $i = 1, 2, \dots, N$, the maximum age difference between resident $i$ and the other residents.
Constraints
- $2 \le N \le 250000$.
- $0 \le A_i \le 10^9$ ($1 \le i \le N$).
- All input values are integers.
Subtasks
- ($25$ points) $N = 2$.
- ($30$ points) $N \le 1000$.
- ($45$ points) No additional constraints.
Input
The input is given in the following format:
$N$ $A_1 \ A_2 \ \dots \ A_N$
Output
Output $N$ lines. On the $i$-th line ($1 \le i \le N$), output the maximum age difference between resident $i$ and the other residents.
Sample Input and Output
Sample Input 1
3 13 15 20
Sample Output 1
7 5 7
- The age differences between resident $1$ and residents $2, 3$ are $2, 7$ years, respectively. Since their maximum value is $7$ years, output $7$ on the $1$-st line.
- The age differences between resident $2$ and residents $1, 3$ are $2, 5$ years, respectively. Since their maximum value is $5$ years, output $5$ on the $2$-nd line.
- The age differences between resident $3$ and residents $1, 2$ are $7, 5$ years, respectively. Since their maximum value is $7$ years, output $7$ on the $3$-rd line.
This sample input satisfies the constraints of Subtasks $2, 3$.
Sample Input 2
2 100 100
Sample Output 2
0 0
- The age difference between resident $1$ and resident $2$ is $0$ years. Therefore, output $0$ on the $1$-st line.
- The age difference between resident $2$ and resident $1$ is $0$ years. Therefore, output $0$ on the $2$-nd line.
This sample input satisfies the constraints of all subtasks.
Sample Input 3
10 440894064 101089692 556439322 34369336 98417847 216265879 623843484 554560874 247445405 718003331
Sample Output 3
406524728 616913639 522069986 683633995 619585484 501737452 589474148 520191538 470557926 683633995
This sample input satisfies the constraints of Subtasks $2, 3$.