#include #include #include using namespace std; vector divisor(long long n) { vector s; for (long long i = 1; i*i<= n; i++) { if (n%i == 0) { s.push_back(i); if (i*i != n) { s.push_back(n / i); } } } sort(s.begin(), s.end()); return s; } int main() { int n, i, x[100000], dp[100000]; cin >> n; for (i = 1; i <= n; i++) { cin >> x[i]; } sort(x + 1, x + n + 1); for (i = 1; i <= 100000; i++) { dp[i] = 0; } for (i = 1; i <= n; i++) { dp[x[i]] = 1; } for (i = 1; i <= 100000; i++) { if (dp[i]) { auto v = divisor(i); for (int j : v) { if(j != i) { dp[i] = max(dp[i], dp[j] + 1); } } } } int ans = 0; for (i = 1; i <= n; i++) { ans = max(ans, dp[x[i]]); } cout << ans << endl; }