#include using namespace std; // Longest Increasing Subsequence の長さを返す。広義単調増加。 template auto LIS_weak_size(const vector &vs){ const auto n = vs.size(); constexpr T inf = numeric_limits::max(); vector A(n + 1, inf); for (auto v : vs) A[distance(A.begin(), upper_bound(A.begin(), A.end(), v))] = v; return distance(A.begin(), lower_bound(A.begin(), A.end(), inf)); } int main() { int N; cin >> N; vector As(N); for (auto &a : As) cin >> a; for (int i = 0; i < N; ++i) As[i] -= i; cout << N - LIS_weak_size(As) << endl; return 0; }