Score : $600$ points
We have a sequence of length $N$ consisting of non-negative integers. Consider performing the following operation on this sequence until the largest element in this sequence becomes $N-1$ or smaller. (The operation is the same as the one in Problem D.)
It can be proved that the largest element in the sequence becomes $N-1$ or smaller after a finite number of operations.
You are given the sequence $a_i$. Find the number of times we will perform the above operation.
Input is given from Standard Input in the following format:
$N$ $a_1$ $a_2$ ... $a_N$
Print the number of times the operation will be performed.
4 3 3 3 3
0
3 1 0 3
1
2 2 2
2
7 27 0 0 0 0 0 0
3
10 1000 193 256 777 0 1 1192 1234567891011 48 425
1234567894848