The Marijuana
Limits: 2 sec., 256 MiB
John and Brus have \(N\) different types of marijuana. The types are numbered from 1 to \(N\). They are going to plant \(N\) stems (one of each type) in a row. A steam of the \(j\)-th type of marijuana will grow normally if there are no other stems closer than \(A_j\) meters to it. It means no other stems should be planted closer than \(A_j\) meters to the left and closer than \(A_j\) meters to the right of it.
John and Brus would like to plant the stems in a way to minimize the distance between the first and the last stems in a row. You have to find the sequence of stems which gives the smallest possible distance between the first and the last stems. If there are many such sequences you have to choose lexicographically the smallest one. One sequence is considered to be lexicographically smaller than another if it has smaller term at the first position the sequences differ.
Input
The first line contains integer number \(N\). The following line contains \(N\) integers \(A_1\), ..., \(A_N\) separated with single spaces.
Output
Print the required sequence of \(N\) integers separated with single spaces.
Constraints
\(1 \le N \le 100\),
\(1 \le A_j \le 100\).
Samples
Input (stdin) | Output (stdout) |
---|---|
3 4 7 5 | 1 3 2 |
Notes
The minimal possible distance between the first and the last stems is 12. The sequence 1 2 3 gives us the distance 14 which is greater. Note that sequences 2 1 3, 2 3 1 and 3 1 2 give minimal possible distance as well, but they are lexicographically greater than the sequence 1 3 2.
Submit a solution
Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
---|
Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
---|