You are a builder in the kingdom, and to protect it, the king has ordered to construct watchtowers each of height , where watchtower is installed at .
After constructing the towers, You have realised that there are watchtowers that can’t see other towers because there are other towers blocking the view.
Watchtower can see watchtower if you can draw a straight line from tower to tower without it intersecting with the body of any other tower (but it can intersect with the top of another tower).
As this kingdom is a magical kingdom, You can use magic to increase the height of any tower you like by an integer , but you can only use it once, and because using magic is hard, you want to increase it by the minimum height such that the tower you chose now can see every other tower.
The king is going to do a suprise checkup visit to one of the towers, so you have to determine for each tower the minimum height to be increased such that you can see every other tower from the top of it.
It can be proven, that under the given conditions, the answer of each tower is always an integer.
Input
The input file consists of:
- a line containing integer
- a line containing the integers .
Output
The output file must contain a single line consisting of the integers .
Constraints and clarifications
- for each
# | Points | Restrictions |
---|---|---|
1 | 0 | Examples |
2 | 20 | |
3 | 31 | |
4 | 49 | No additional limitations. |
Example 1
stdin
5
4 3 1 3 4
stdout
1 0 1 0 1
Explanation
In the first sample case, tower cannot see tower because tower is blocking the view, so increaseing by would make it visible, and same goes for and .
Example 2
stdin
2
3 7
stdout
0 0
Explanation
In the second sample case, both towers can see eachother, so no need to increase either of them.