You are given an array of integers .
Every second, the following operation is performed simultaneously for all positions :
All replacements use the values from the beginning of that second.
For each position, find how many times its value changes before the array stops changing. The initial assignment of values does not count as a change.
Here, is the number of times the value at position changes before the array stops changing.
The successive arrays are:
.
The values at positions , , , and change , , , and times, respectively. Position stays unchanged for two seconds before changing to .
The successive arrays are:
.
Position changes from to and later to . Both neighboring occurrences of reach it in the first second, but that is only one change. Position never changes, and each remaining position changes once.