#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int co[300030] = {}; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { int a; cin >> a; int m = 1; for (int j = 1; j * j <= a; j++) { if (a % j == 0) { if (a != 1 && m < co[j] + 1) { m = co[j] + 1; } if (j != 1 && m < co[a / j] + 1) { m = co[a / j] + 1; } } } co[a] = max(co[a], m); } int ans = 0; for (int i = 1; i < 300030; i++) { if (ans < co[i]) { ans = co[i]; } } cout << ans << endl; }