CSES - Collecting Numbers | Thu thập số

View as PDF



Authors:
Problem types
Points: 1400 (p) Time limit: 1.0s Memory limit: 512M Input: stdin Output: stdout

You are given an array that contains each number between \(1\ldots n\) exactly once. Your task is to collect the numbers from \(1\) to \(n\) in increasing order.

On each round, you go through the array from left to right and collect as many numbers as possible. What will be the total number of rounds?

Input

  • The first line has an integer \(n:\) the array size.
  • The next line has \(n\) integers \(x_1,x_2,\ldots,x_n:\) the numbers in the array.

Output

  • Print one integer: the number of rounds.

Constraints

  • \(1 \leq n \leq 2 \cdot 10^5\)

Example

Sample input

5
4 2 1 5 3

Sample output
3


Comments (6)

Most recent
Loading comments...