#!/usr/bin/ python3.8 import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N, *A = map(int, read().split()) def longest_increasing_subsequence(seq, wider_sense=True): from bisect import bisect_left, bisect_right f = bisect_right if wider_sense else bisect_left N = len(seq) INF = 10**18 dp = [INF] * (N + 1) for x in seq: if x <= 0: continue i = f(dp, x) dp[i] = x return f(dp, INF - 1) B = [x - i for i, x in enumerate(A)] answer = N - longest_increasing_subsequence(B) print(answer)