An unknown permutation contains each integer from to exactly once.
For each position , let be the distance to the nearest position containing a larger value:
If no larger value exists, let .
You are given . Construct a permutation with exactly these reports, or determine that no such permutation exists.
If no valid permutation exists, output -1 instead. If several permutations satisfy the reports, output any of them.
At position , the nearest larger value is at position , at distance .
The only value larger than the value at position is at position , at distance .
The largest value must be at position , so position has a larger value at distance , contradicting its report.
The only permutation is .