IntermediateRating 1400
Most Chunks to Sort
Split the permutation of 0 … n−1 into as many consecutive chunks as possible so that sorting each chunk separately and joining them gives a sorted list. Print the number of chunks.
Input
n, then the permutation.
Output
One integer.
Sample 1
Input
5 4 3 2 1 0
Output
1
Sample 2
Input
5 1 0 2 3 4
Output
4
Output appears here