#include using namespace std; #define rep(i,n) for(int i=0;i<(n);++i) #define reps(i,n) for(int i=1;i<=(n);++i) #define all(x) (x).begin(),(x).end() #define Fixed fixed << setprecision(14) #define int int64_t using pii = pair; constexpr int INF = 0x3f3f3f3f; constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL; constexpr int mod = 1e9+7; constexpr int MOD = 998244353; template inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); } template inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); } template using min_heap = priority_queue,greater >; template using max_heap = priority_queue; template using umap = unordered_map; int gcd(int a,int b){ return b ? gcd(b,a % b) : a;} int lcm(int a,int b){ return a / gcd(a,b) * b;} signed main(){ cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; vector dp(1e5 * 3 + 1); int maxv = 1; rep(i,n){ int a; cin >> a; if(a == 1){ chmax(dp[a],1); }else{ for(int j = 1;j * j <= a;++j){ if(a % j == 0){ chmax(dp[a],dp[j] + 1); if(j * j != a && j != 1){ chmax(dp[a],dp[a / j]+1); } } } } chmax(maxv,dp[a]); } cout << maxv << '\n'; return 0; }