Preparando MOJI
You have a permutation $$$p$$$ of integers from $$$1$$$ to $$$n$$$.
You have a strength of $$$s$$$ and will perform the following operation some times:
It can be shown that no matter what $$$i$$$ you have chosen, $$$p$$$ will be a permutation of integers from $$$1$$$ to $$$|p|$$$ after all operations.
You want to be able to transform $$$p$$$ into the empty permutation. Find the minimum strength $$$s$$$ that will allow you to do so.
The first line of input contains a single integer $$$n$$$ ($$$1 \leq n \leq 5 \cdot 10^5$$$) — the length of the permutation $$$p$$$.
The second line of input conatains $$$n$$$ integers $$$p_1, p_2, \ldots, p_n$$$ ($$$1 \leq p_i \leq n$$$) — the elements of the permutation $$$p$$$.
It is guaranteed that all elements in $$$p$$$ are distinct.
Print the minimum strength $$$s$$$ required.
3 3 2 1
1
1 1
0
10 1 8 4 3 7 10 6 5 9 2
1
In the first test case, the minimum $$$s$$$ required is $$$1$$$.
Here is how we can transform $$$p$$$ into the empty permutation with $$$s=1$$$:
It can be shown that with $$$s=0$$$, it is impossible to transform $$$p$$$ into the empty permutation.