import std.stdio; import std.algorithm; import std.string; import std.conv; import std.range; void main() { enum MAX_N = 10 ^^ 5, MAX_X = 10 ^^ 6; int[10 ^^ 5] buf; immutable n = readln.chomp.to!int; readln.splitter.map!(to!int).copy(buf[]); auto set = buf[0..n].sort(); int[int] cache; foreach_reverse (x; set) { cache[x] = iota(2 * x, MAX_X, x) .filter!(i => set.contains(i)) .map!(i => cache[i]) .fold!max(0) + 1; } writeln(cache.values.fold!max); }