#include #ifndef LOCAL_ #define fprintf if( false ) fprintf #endif // LOCAL_ #define dumpi(x1) fprintf(stderr, "#%s.%d (%s) = (%d)\n", __func__, __LINE__, #x1, x1); #define dumpii(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%d, %d)\n", __func__, __LINE__, #x1, #x2, x1, x2); #define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1); #define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1); int n; int xs[1123456]; int main() { scanf("%d", &n); for(int i = 0; i < n; ++i) { int a; scanf("%d", &a); xs[a] = 1; } int limit = sqrt(1123456); for(int i = 1; i < limit; ++i) { if( xs[i] == 0 ) continue; for(int j = i + i; j < 1123456; j+=i) { if( xs[j] != 0 ) xs[j] = std::max(xs[j], xs[i] + 1); } } int res = -1; for(int i = 0; i < 1123456; ++i) { // if( i < 100 ) dumpi(xs[i]); res = std::max(res, xs[i]); } printf("%d\n", res); return 0; }