n = int(input())
l = list(map(int,input().split()))
killed = 0
last_killed = n
for i in range(n-1,-1,-1):
cur_kill = max(0,i-l[i])
if cur_kill >= last_killed:
continue
if i < last_killed:
killed += i - cur_kill
else:
killed += last_killed - cur_kill
if cur_kill == 0:
break
last_killed = min(last_killed,cur_kill)
print(n - killed)
#include <bits/stdc++.h>
using namespace std;
#define FAST() \
ios_base::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
#define wTC() \
int t; \
cin >> t; \
for (int i = 1; i <= t; i++) \
{ \
cout << "Case " << i << ": "; \
nasim(); \
}
#define TC() \
int t; \
cin >> t; \
while (t--) \
{ \
nasim(); \
}
#define nTC() \
int t = 1; \
while (t--) \
{ \
nasim(); \
}
#define endl "\n"
#define ll long long int
#define ull unsigned long long int
#define mod 1e9 + 7
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define getunique(v) \
{ \
sort(v.begin(), v.end()); \
v.erase(unique(v.begin(), v.end()), v.end()); \
}
void nasim()
{
ll n;
cin>>n;
ll arr[n+4];
for(ll i=0;i<n;i++)
{
cin>>arr[i];
}
ll life = arr[n-1];
ll cnt =0;
for(ll i=n-2;i>=0;i--)
{
if(life!=0)
{
cnt++;
life = max(arr[i],life-1);
}
else
{
life = max(arr[i],life-1);
}
}
cout<<n-cnt<<endl;
}
int main()
{
FAST()
/*
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
*/
nTC();
// TC();
// wTC();
}
74. Search a 2D Matrix | 71. Simplify Path |
62. Unique Paths | 50. Pow(x, n) |
43. Multiply Strings | 34. Find First and Last Position of Element in Sorted Array |
33. Search in Rotated Sorted Array | 17. Letter Combinations of a Phone Number |
5. Longest Palindromic Substring | 3. Longest Substring Without Repeating Characters |
1312. Minimum Insertion Steps to Make a String Palindrome | 1092. Shortest Common Supersequence |
1044. Longest Duplicate Substring | 1032. Stream of Characters |
987. Vertical Order Traversal of a Binary Tree | 952. Largest Component Size by Common Factor |
212. Word Search II | 174. Dungeon Game |
127. Word Ladder | 123. Best Time to Buy and Sell Stock III |
85. Maximal Rectangle | 84. Largest Rectangle in Histogram |
60. Permutation Sequence | 42. Trapping Rain Water |
32. Longest Valid Parentheses | Cutting a material |
Bubble Sort | Number of triangles |
AND path in a binary tree | Factorial equations |