Reverse collection of beans
As mentioned in the previous problem, Petya is fond of playing a game with peas. The game involves N bowls arranged in a circle, each containing a certain number of peas. During each turn, Petya takes all the peas from a specific bowl and distributes them one by one into each subsequent bowl. On the first move, he takes peas from the first bowl, and on each following move, he starts from the bowl where the last pea was placed in the previous move. After several moves, Petya finds himself in a situation where he must take peas from the first bowl again. Now, he is curious about what the configuration was one move prior.
Input
The first line of the input specifies the number of bowls N (1 ≤ N ≤ 10^5). The second line contains N integers a_i, representing the number of peas in each bowl (0 ≤ a_i ≤ 10^9, a_1 = 0) in the current configuration.
Output
In a single line, output N integers representing the number of peas in each bowl on the previous move. If there are multiple possible previous states, you may output any one of them. If no such state exists, output the single number −1.