import java.io.FileNotFoundException; import java.io.PrintWriter; import java.util.Arrays; import java.util.Comparator; import java.util.Scanner; public class Main { public static void main(String[] args) throws FileNotFoundException { new Main().run(); } void run() { Scanner sc = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); int N = sc.nextInt(); long[] A = new long[N]; for (int i = 0; i < N; ++i) { A[i] = sc.nextLong() - i + N; } A = shrink(A); int[] dp = new int[N + 1]; Arrays.fill(dp, Integer.MAX_VALUE / 3); for (int i = 0; i < N; ++i) { int idx = Arrays.binarySearch(dp, (int) A[i]); if (idx >= 0) { dp[idx + 1] = (int) A[i]; } else { idx = -(idx + 1); dp[idx] = (int) A[i]; } } int ans = 0; for (int i = 0; i < dp.length; ++i) { if (dp[i] == Integer.MAX_VALUE / 3) continue; ans = Math.max(ans, i + 1); } System.out.println(N - ans); } long[] shrink(long[] a) { int n = a.length; long[] ret = new long[n]; long[][] x = new long[n][2]; for (int i = 0; i < n; ++i) { x[i][0] = i; x[i][1] = a[i]; } Arrays.sort(x, new Comparator() { @Override public int compare(long[] o1, long[] o2) { return Long.compare(o1[1], o2[1]); } }); int p = 1; for (int i = 0; i < n; ++i) { ret[(int) x[i][0]] = p; if (i + 1 < n && x[i][1] != x[i + 1][1]) ++p; } return ret; } static void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }