#include using namespace std; typedef long long ll; typedef pair l_l; typedef pair i_i; template inline bool chmax(T &a, T b) { if(a < b) { a = b; return true; } return false; } template inline bool chmin(T &a, T b) { if(a > b) { a = b; return true; } return false; } #define EPS (1e-7) #define INF (1e9) #define PI (acos(-1)) //const ll mod = 1000000007; ll N; ll A[300001]; ll dp[300001]; vector Div(int a) { vector ret; for(int i = 1; i * i <= a; i++) { if(a % i != 0) continue; ret.push_back(i); if(i * i != a) ret.push_back(a / i); } return ret; } int main() { //cout.precision(10); cin.tie(0); ios::sync_with_stdio(false); cin >> N; for(int i = 0; i < N; i++) cin >> A[i]; sort(A, A + N); for(int i = 1; i <= 3e5; i++) dp[i] = 1; ll ans = 0; for(int i = N - 1; i >= 0; i--) { //for(int i = 0; i <= 10; i++) cerr << dp[i] << " "; //cerr << endl; ll New = dp[A[i]] + 1; chmax(ans, dp[A[i]]); vector v = Div(A[i]); for(auto val : v) { if(val == A[i]) continue; chmax(dp[val], New); } } cout << ans << endl; return 0; }