An array of
integers can be transformed into a new array through this process:
is modified to be the maximum of
and
for all
.
An array is stable if it remains the same after the above transformation is performed on the array. For example, is a stable array.
It can be proven that array , after a certain number of transformations, will result in a stable array. Can you print out the minimum number of transformations on array
to transform it into a stable array?
Input Specification
The first line will contain the integer
.
The second line will contain the array
.
Output Specification
Output the number of minimum transformations to transform into a stable array.
Sample Input
5
1 3 2 4 5
Sample Output
4
Comments
How can
be modified to be the maximum of
and
?