B. Vladik and Complicated Book
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Vladik had started reading a complicated book about algorithms containing n pages. To improve understanding of what is written, his friends advised him to read pages in some order given by permutationP = [p1, p2, ..., pn], where pi denotes the number of page that should be readi-th in turn.
Sometimes Vladik’s mom sorted some subsegment of permutation