// 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[1000005]; int cmp(const void *a, const void *b) { return *(int *)a - *(int *)b; } int main() { int i, j, k, max; N = in(); for (i = 0; i < N; i++) x[i] = in(); qsort(x, N, sizeof(int), cmp); max = x[N-1]; for (i = 0; i < N; i++) { k = x[i]; for (j = k << 1; j <= max; j+=k) { if (dp[k]+1 > dp[j]) dp[j] = dp[k]+1; } } max = 0; for (i = 0; i < N; i++) if (dp[x[i]] > max) max = dp[x[i]]; printf("%d\n", max+1); return 0; }