Popping Balloons

Pop every balloon from left to right with the fewest rightward arrows that drop one unit after each hit.

Medium4GreedyHash mapInterviewNo attempts yetTime limit2sMemory limit256 MB

Problem

NN balloons float in a large room, lined up from left to right. Jinsol likes archery and always shoots to the right, starting from the left side of the room. She picks the height of each shot herself.

An arrow flies to the right at the chosen height HH and pops the first balloon it meets at that height. The popped balloon disappears, and the arrow keeps flying to the right one unit lower, at height H1H-1.

Jinsol wants to pop every balloon. Find the smallest number of arrows that does it.

Input

The first line has the integer NN.

The second line has the heights H1,H2,,HNH_1, H_2, \dots, H_N of the NN balloons, in order from left to right. HiH_i is the height of the ii-th balloon from the left.

  • 1N1061 \le N \le 10^6
  • 1Hi1061 \le H_i \le 10^6

Output

Print the smallest number of arrows needed to pop every balloon.

Hint

In the first example one arrow pops the balloons at heights 5, 4, and 3, and a second arrow pops the balloons at heights 2 and 1. Two arrows are enough.