#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 2;
int a[N];
int f[N];
int n;
int res;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
for (int i = 1; i <= n; ++i) cin >> a[i];
for (int i = 1; i <= n; ++i)
for (int j = i; j >= 1; --j) {
f[j] = max(f[j - 1], f[j] + (i - j == a[i]));
res = max(res, f[j]);
}
cout << res;
return 0;
}