#include <bits/stdc++.h>
#define msg(x) cout << #x << " = " << x << endl
using namespace std;
int n, x;
multiset<int> s;
multiset<int>::iterator it;
int main() {
cin.sync_with_stdio(0); cin.tie(0);
cin >> n;
for (int i = 0; i < n; i++) {
cin >> x;
if (x - i > 0) {
//this part is fastest way (code-wise) i know of finding
//longest non-decreasing subsequence
//if you simply want longest increasing, replace multiset with set
x -= i;
s.insert(x);
it = upper_bound(s.begin(), s.end(), x);
if (it != s.end()) s.erase(it);
}
}
cout << n - s.size() << endl;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgbXNnKHgpIGNvdXQgPDwgI3ggPDwgIiA9ICIgPDwgeCA8PCBlbmRsCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbiwgeDsKbXVsdGlzZXQ8aW50PiBzOwptdWx0aXNldDxpbnQ+OjppdGVyYXRvciBpdDsKCmludCBtYWluKCkgewogICAgY2luLnN5bmNfd2l0aF9zdGRpbygwKTsgY2luLnRpZSgwKTsKICAgIGNpbiA+PiBuOwogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBuOyBpKyspIHsKICAgICAgICBjaW4gPj4geDsKICAgICAgICBpZiAoeCAtIGkgPiAwKSB7CiAgICAgICAgICAgIC8vdGhpcyBwYXJ0IGlzIGZhc3Rlc3Qgd2F5IChjb2RlLXdpc2UpIGkga25vdyBvZiBmaW5kaW5nCiAgICAgICAgICAgIC8vbG9uZ2VzdCBub24tZGVjcmVhc2luZyBzdWJzZXF1ZW5jZQogICAgICAgICAgICAvL2lmIHlvdSBzaW1wbHkgd2FudCBsb25nZXN0IGluY3JlYXNpbmcsIHJlcGxhY2UgbXVsdGlzZXQgd2l0aCBzZXQKICAgICAgICAgICAgeCAtPSBpOwogICAgICAgICAgICBzLmluc2VydCh4KTsKICAgICAgICAgICAgaXQgPSB1cHBlcl9ib3VuZChzLmJlZ2luKCksIHMuZW5kKCksIHgpOwogICAgICAgICAgICBpZiAoaXQgIT0gcy5lbmQoKSkgcy5lcmFzZShpdCk7CiAgICAgICAgfQogICAgfQogICAgY291dCA8PCBuIC0gcy5zaXplKCkgPDwgZW5kbDsKICAgIHJldHVybiAwOwp9Cg==