#include<bits/stdc++.h>
using namespace std;
const int nax = (int)1e5 + 47;
const int INF = (int)1e9 + 47;
int dp[nax];
vector<int> primes;
map<int, int> m;
void resheto(int n)
{
vector<char> prime (n + 1, true);
prime[0] = prime[1] = false;
for (int i = 2; i <= n; ++i)
if (prime[i]){
primes.push_back(i);
if (i * 1ll * i <= n)
for (int j = i * i; j <= n; j += i)
prime[j] = false;
}
}
int main()
{
resheto(4 * (int)1e4);
int n;
cin >> n;
vector<int> a(n + 1);
for(int i = 1; i <= n; i++)
cin >> a[i];
int mx = 0;
for(int i = 1; i <= n; i++)
{
vector<int> fct;
for(auto x : primes)
{
bool ok = false;
while(a[i] % x == 0 )
{
ok = true;
a[i] /= x;
}
if(ok)
fct.push_back(x);
}
if(a[i] != 1)
fct.push_back(a[i]);
for(auto x : fct)
if(m.count(x))
dp[i] = max(dp[i], m[x] + 1);
mx = max(mx, dp[i]);
dp[i] = mx;
for(auto x : fct)
m[x] = max(m[x], dp[i]);
}
cout << dp[n] << '\n';
return 0;
}