题目描述
Problem Description
Angel G-san and demon V-san attend a high school in the human world.
Today, they were assigned summer homework! The summer vacation lasts for $ N $ days, and the homework consists of $ N $ pages.
Demon V-san, being organized, decided to do one page of homework each day.
However, angel G-san, who is busy bringing blessings to the human world (under the guise of this), doesn't have time for homework!
Therefore, G-san decided to copy V-san's homework.
When G-san visits V-san on the $ i $-th day, V-san's mood is $ a_i $, and G-san can copy up to $ a_i $ pages of homework that day.
Since G-san is busy, she doesn't want to visit V-san more than necessary. How many times does G-san need to visit V-san minimally to complete the homework?
Note that when G-san visits V-san on the $ i $-th day, V-san will have already completed the $ i $-th page of homework.
Also, note that G-san cannot copy pages $ i+1 $ and beyond on the $ i $-th day.
Additionally, G-san cannot visit V-san more than once on the same day.
Input Format
The input is given from the standard input in the following format:
$ N $
$ a_1 $ $ a_2 $ $\ldots$ $ a_{N-1} $ $ a_N $
Output Format
Output the minimum number of times G-san needs to visit V-san to the standard output.
Sample Input and Output
Sample Input #1
5
1 3 2 2
Sample Output #1
2
Sample Input #2
6
1 2 1 1 2
Sample Output #2
4
Sample Input #3
8
1 2 1 2 3 1 3
Sample Output #3
3
Notes/Hints
Constraints
- All inputs are integers.
- $1\leq\ N\leq2\times10^5$
- $1\leq\ a_i\leq\ 10^9$
Sample Explanation 1
It is sufficient to visit on the 3rd and 5th days.
Sample Explanation 2
For example, it is sufficient to visit on the 1st, 3rd, 4th, and 6th days.
Sample Explanation 3
For example, it is sufficient to visit on the 3rd, 6th, and 8th days.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分