from bisect import bisect_right n = int(input()) A = list(map(int, input().split())) A = [a - i for i, a in enumerate(A)] m = 10**6 A = [1] * m + A B = [] for a in A: p = bisect_right(B, a) if p == len(B): B.append(a) else: B[p] = a print(n + m - len(B))