#ifdef LOCAL
#include <local.hpp>
#else
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
#define debug(...) (static_cast<void>(0))
#define postprocess() (static_cast<void>(0))
#endif

// #include "atcoder/dsu.hpp"
// #include "atcoder/modint.hpp"
// using mint = atcoder::modint998244353;
// using mint = atcoder::modint1000000007;

using namespace std;
using ll = long long;
using ld = long double;

vector<int> divisors(int n) {
    vector<int> res;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.push_back(i);
            if (i * i != n) {
                res.push_back(n / i);
            }
        }
    }
    return res;
}

void solve([[maybe_unused]] int test) {
    int N;
    cin >> N;

    int dp[100001];
    fill(dp, dp + 100001, 0);

    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    reverse(A.begin(), A.end());

    for (auto&& x : A) {
        int lis = dp[x];
        for (auto&& d : divisors(x)) {
            dp[d] = max(dp[d], lis + 1);
        }
    }

    cout << *max_element(dp, dp + 100001) << endl;
}

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr);

    int t = 1;
    // cin >> t;
    for (int _t = 1; _t <= t; _t++) solve(_t);

    postprocess();
}