#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int &x : a)
        cin >> x;
    int V = *max_element(a.begin(), a.end());
    vector<int> spf(V + 1), best(V + 1);
    for (int i = 2; i <= V; i++)
        if (!spf[i])
            for (int j = i; j <= V; j += i)
                if (!spf[j])
                    spf[j] = i;
    int ans = 1;
    for (int x : a) {
        vector<int> ps;
        while (x > 1) {
            int p = spf[x];
            ps.push_back(p);
            while (x % p == 0)
                x /= p;
        }
        int cur = 1;
        for (int p : ps)
            cur = max(cur, best[p] + 1);
        for (int p : ps)
            best[p] = max(best[p], cur);
        ans = max(ans, cur);
    }
    cout << ans << '\n';
}
