#include <bits/stdc++.h>
using namespace std;
bool h[1000009]={0};
int dp[1000009]={0};
int a[1000009]={0};
vector<int> v[1000009];
int main()
{
int n,x,m=0,ans=0;
scanf("%d",&n);
for(int i=0;i<n;i++)
{
scanf("%d",&a[i]);
h[a[i]]=1;
m=max(a[i],m);
}
sort(a,a+n);
for(int i=0;i<n;i++)
{
int p=0;
if(h[a[i]])
for(vector<int>::iterator it=v[a[i]].begin();it!=v[a[i]].end();it++)
{
p=max(p,dp[*it]);
}
dp[a[i]]=1+p;
ans=max(ans,dp[a[i]]);
for(int j=2;a[i]*j<=m;j++)
{
if(h[a[i]*j]==1)
{
v[a[i]*j].push_back(a[i]);
}
}
}
printf("%d\n",ans);
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmJvb2wgaFsxMDAwMDA5XT17MH07CmludCBkcFsxMDAwMDA5XT17MH07CmludCBhWzEwMDAwMDldPXswfTsKdmVjdG9yPGludD4gdlsxMDAwMDA5XTsKaW50IG1haW4oKQp7CglpbnQgbix4LG09MCxhbnM9MDsKCXNjYW5mKCIlZCIsJm4pOwoJZm9yKGludCBpPTA7aTxuO2krKykKCXsKCQlzY2FuZigiJWQiLCZhW2ldKTsKCQloW2FbaV1dPTE7CgkJbT1tYXgoYVtpXSxtKTsKCX0KCXNvcnQoYSxhK24pOwoJZm9yKGludCBpPTA7aTxuO2krKykKCXsKCQlpbnQgcD0wOwoJCWlmKGhbYVtpXV0pCgkJZm9yKHZlY3RvcjxpbnQ+OjppdGVyYXRvciBpdD12W2FbaV1dLmJlZ2luKCk7aXQhPXZbYVtpXV0uZW5kKCk7aXQrKykKCQl7CgkJCXA9bWF4KHAsZHBbKml0XSk7CgkJfQoJCWRwW2FbaV1dPTErcDsKCQlhbnM9bWF4KGFucyxkcFthW2ldXSk7CgkJZm9yKGludCBqPTI7YVtpXSpqPD1tO2orKykKCQl7CgkJCWlmKGhbYVtpXSpqXT09MSkKCQkJewoJCQkJdlthW2ldKmpdLnB1c2hfYmFjayhhW2ldKTsKCQkJfQoJCX0KCX0KCXByaW50ZigiJWRcbiIsYW5zKTsKCXJldHVybiAwOwp9