#include #define MOD 1000000007 using namespace std; int N; int num[100001] = {0}; int dp[1000001] = {0}; vector divisor(int n) { if (n == 1) return {}; vector res; for (int i = 1; i * i <= n; i++) { if (n % i == 0) { res.emplace_back(i); if (i != 1 && i != n / i) res.emplace_back(n / i); } } return res; } int main(void){ cin >> N; int i; for(i = 0; i < N; ++i){ cin >> num[i]; } sort(num, num + N); for(auto i : num){ dp[i] = 1; auto k = divisor(num[i]); for(auto j : k) dp[i] = max(dp[i], dp[j] + 1); } int result = 0; for(i = 0; i < N; ++i) result = max(result, dp[num[i]]); cout << result << endl; return 0; }