#include using namespace std; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } #define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl template ostream& operator << (ostream &s, pair P) { return s << '<' << P.first << ", " << P.second << '>'; } template ostream& operator << (ostream &s, vector P) { for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; } template ostream& operator << (ostream &s, vector > P) { for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; } template ostream& operator << (ostream &s, set P) { for(auto it : P) { s << "<" << it << "> "; } return s << endl; } template ostream& operator << (ostream &s, map P) { for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; } vector divisor(long long n) { vector res; for (long long i = 1; i * i <= n; ++i) { if (n % i == 0) { res.push_back(i); long long j = n / i; if (j != i) res.push_back(j); } } sort(res.begin(), res.end()); return res; } const int MAX = 310000; int main() { int N; cin >> N; vector A(N); for (int i = 0; i < N; ++i) cin >> A[i]; vector dp(MAX, 0); for (auto a : A) { if (a == 1) dp[a] = 1; else { const auto& div = divisor(a); for (auto d : div) if (d < a) chmax(dp[a], dp[d] + 1); } } int res = 0; for (int i = 0; i < MAX; ++i) chmax(res, dp[i]); cout << res << endl; }