#include using namespace std; int main() { int n; cin >> n; vector a(n); for (int i = 0; i < n; i++) cin >> a.at(i); vector> d(300001); for (int i = 1; i <= 300000; i++) { for (int j = 1; j * j <= i; j++) { if (i % j) continue; d.at(i).push_back(j); d.at(i).push_back(i / j); } } vector dp(300001); for (int i = 0; i < n; i++) { dp.at(a.at(i)) = max(dp.at(a.at(i)), 1); for (int x : d.at(a.at(i))) { if (x == a.at(i)) continue; dp.at(a.at(i)) = max(dp.at(a.at(i)), dp.at(x) + 1); } } cout << *max_element(dp.begin(), dp.end()) << endl; }