import std.stdio, std.array, std.string, std.conv, std.algorithm; import std.typecons, std.range, std.random, std.math, std.container; import std.numeric, std.bigint, core.bitop, std.bitmanip; immutable int INF = 1 << 29; void main() { auto N = readln.chomp.to!int; auto A = readln.split.map!(to!long).array; long[] B; int ans = 0; foreach (i; 0..N) { if (A[i] - i > 0) { B ~= A[i] - i; } else { ans += 1; } } N = B.length.to!int; auto C = B.dup; C = C.sort().uniq().array; int[long] comp; foreach (i; 0..C.length.to!int) comp[C[i]] = i; auto dp = new int[](N+1); fill(dp, INF); dp[0] = -1; foreach (i; 0..N) { int b = comp[B[i]]; int lb = dp.assumeSorted.lowerBound(b+1).length.to!int; dp[lb] = b; } int tmp = 0; foreach (i; 0..N+1) if (dp[i] < INF) tmp = N - i; ans += tmp; ans.writeln; }