// yukicoder: No.390 最長の数列 // 2019.5.6 bal4u #include #include #if 1 #define gc() getchar_unlocked() #define pc(c) putchar_unlocked(c) #else #define gc() getchar() #define pc(c) putchar(c) #endif int in() // 非負整数の入力 { int n = 0, c = gc(); do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0'); return n; } int x[100005], N; int dp[100005]; int f[1000005]; int cmp(const void *a, const void *b) { return *(int *)a - *(int *)b; } int main() { int i, j, k, max, ans; N = in(); for (i = 0; i < N; i++) x[i] = in(); qsort(x, N, sizeof(int), cmp); for (i = 0; i < N; i++) f[x[i]] = i; max = x[N-1]; for (i = 0; i < N; i++) { k = x[i]; for (j = k << 1; j <= max; j+=k) if (f[j]) { if (dp[i]+1 > dp[f[j]]) dp[f[j]] = dp[i]+1; } } ans = 0; for (i = 0; i < N; i++) if (dp[i] > ans) ans = dp[i]; printf("%d\n", ans+1); return 0; }