n = int(input()) *a, = map(int,input().split()) for i in range(n): a[i] -= i from bisect import bisect_left, bisect_right INF = 1<<60 dp = [INF]*n for i in a: idx = bisect_right(dp,i) if idx: dp[idx] = i elif i > 0: dp[idx] = i #dp[bisect_right(dp,i)] = i print(n-bisect_left(dp,INF))