void main(){ import std.stdio, std.string, std.conv, std.algorithm; import std.typecons; int n; rd(n); auto a=readln.split.to!(int[]); auto rec=new int[](n); fill(rec, 1); sort(a); size_t[int] pos; foreach(i, e; a) pos[e]=i; foreach(i, e; a){ for(auto t=2; e*t<=1_000_000; t++){ if(e*t in pos){ auto j=pos[e*t]; rec[j]=max(rec[j], rec[i]+1); } } } writeln(reduce!(max)(rec)); } void rd(T...)(ref T x){ import std.stdio, std.string, std.conv; auto l=readln.split; assert(l.length==x.length); foreach(i, ref e; x){ e=l[i].to!(typeof(e)); } }