#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MAX 1000000
ll a[2000000];
ll dp[2000000];
int main()
{
ll n,i,j,num,ans=0;
scanf("%d",&n);

for(i=0;i<n;i++)
{
    scanf("%d",&a[i]);
    dp[a[i]]=1;
}

for(i=0;i<n;i++)
{
    num=a[i];
    for(j=2*num;j<=MAX;j+=num)
        dp[j]=max(dp[j],1+dp[num]);
    ans=max(ans,dp[num]);
}
printf("%d",ans);
return 0;
}


#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <queue>
using namespace std;
typedef pair<int,int> Pii;
typedef long long LL;
typedef unsigned long long ULL;
#define MST(a,b) memset(a,b,sizeof(a))
#define CLR(a) MST(a,0)
#define Pow2(a) (a*a)

const int maxn=1e6+10;
int N,ans;
int inpt[maxn];
int pos[maxn];
int dp[maxn];

void DP(int,int);

int main()
{
	scanf("%d\n", &N);
	for(int i=1; i<=N; i++)
	{
		scanf("%d", &inpt[i]);
		pos[inpt[i]]=i;
	}
	for(int i=1; i<=N; i++)
	{
		if(!dp[i])
		{
			dp[i]=1;
			DP(i,inpt[i]);
		}
		ans=max(ans,dp[i]);
	}
	printf("%d\n", ans);
	return 0;
}

void DP(int np, int num)
{
	if(dp[np]) return;
	for(int i=2; (LL)i*num<maxn; i++)
	{
		if(pos[i*num])
		{
			dp[pos[i*num]]=max(dp[pos[i*num]], dp[np]+1);
			DP(pos[i*num], i*num);
		}
	}
}


#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <queue>
using namespace std;
typedef pair<int,int> Pii;
typedef long long LL;
typedef unsigned long long ULL;
#define MST(a,b) memset(a,b,sizeof(a))
#define CLR(a) MST(a,0)
#define Pow2(a) (a*a)

const int maxn=1e6+10;
int N,ans;
int inpt[maxn];
int pos[maxn];
int dp[maxn];
bool vis[maxn];

void DP(int,int);

int main()
{
	scanf("%d\n", &N);
	for(int i=1; i<=N; i++)
	{
		scanf("%d", &inpt[i]);
		pos[inpt[i]]=i;
	}
	for(int i=1; i<=N; i++)
	{
		if(!vis[i])
		{
			DP(i,inpt[i]);
			dp[i]=1;
		}
		ans=max(ans,dp[i]);
	}
	printf("%d\n", ans);
	return 0;
}

void DP(int np, int num)
{
	vis[np]=1;
	for(int i=2; (LL)i*num<maxn; i++)
	{
		if(pos[i*num]&&!vis[i*num])
		{
			dp[pos[i*num]]=max(dp[pos[i*num]], dp[np]+1);
			DP(pos[i*num], i*num);
		}
	}
}


#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <queue>
using namespace std;
typedef pair<int,int> Pii;
typedef long long LL;
typedef unsigned long long ULL;
#define MST(a,b) memset(a,b,sizeof(a))
#define CLR(a) MST(a,0)
#define Pow2(a) (a*a)

const int maxn=1e6+10;
int N,ans;
int inpt[maxn];
int pos[maxn];
int dp[maxn];

int DP(int,int);

int main()
{
	scanf("%d\n", &N);
	for(int i=1; i<=N; i++)
	{
		scanf("%d", &inpt[i]);
		pos[inpt[i]]=i;
	}
	for(int i=1; i<=N; i++)
	{
		if(!dp[i])
		{
			DP(i,inpt[i]);
		}
		ans=max(ans,dp[i]);
	}
	printf("%d\n", ans);
	return 0;
}

int DP(int np, int num)
{
	if(dp[np]) return dp[np];
	for(int i=2; (LL)i*num<maxn; i++)
	{
		if(pos[i*num])
		{
			dp[np]=max(dp[np], DP(pos[i*num], i*num)+1);
		}
	}
	if(!dp[np]) dp[np]=1;
	return dp[np];
}


#include<iostream>
#include<cstring>
#include<queue>
#include<cmath>
#include<limits>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<map>
#define inf 0x3f3f3f3f
#define ll long long
using namespace std;
int n;
int dp[1000005],a[1000005];
int main()
{
    //freopen( "testin_01.txt", "r", stdin);
    //freopen( "testout_01.txt", "w", stdout);
    //ios::sync_with_stdio(false);
    memset(dp,0,sizeof(dp));
    scanf("%d",&n);
    for (int i=1;i<=n;i++)
    {
         dp[i]=1;
         scanf("%d",&a[i]);
         for (int j=i-1;j>=1;j--)
              if (a[i]%a[j]==0) dp[i]=max(dp[i],dp[j]+1);
    }
    int maxn=-inf;
    for (int i=1;i<=n;i++)
         maxn=max(maxn,dp[i]);
    printf("%d",maxn);
    return 0;
}


#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <queue>
using namespace std;
typedef pair<int,int> Pii;
typedef long long LL;
typedef unsigned long long ULL;
#define MST(a,b) memset(a,b,sizeof(a))
#define CLR(a) MST(a,0)
#define Pow2(a) (a*a)

const int maxn=1e6+10;
int N,ans;
int inpt[maxn];
bool nprime[maxn];
int tp,plist[maxn];
int nlist[maxn];

map<int,int> dp;

void init();
int get(int,int);
int dfs(int,int,int,int);

int main()
{
	init();
	scanf("%d\n", &N);
	for(int i=1; i<=N; i++) scanf("%d", &inpt[i]);
	for(int i=1; i<=N; i++)
	{
		CLR(nlist);
		int lim=get(1,inpt[i]);//puts("1");
//		for(int j=1; j<=tp; j++) if(nlist[j]) printf("%d %d\n", plist[j], nlist[j]);system("pause");
		dfs(1,1,inpt[i],lim);//puts("2");
		dp[inpt[i]]=dp[inpt[i]]+1;
		//puts("#");
//		printf("%d %d\n", inpt[i], dp[inpt[i]]);
		ans=max(dp[inpt[i]],ans);
	}
	printf("%d\n", ans);
	return 0;
}

void init()
{
	int lim=sqrt(maxn);
	for(int i=2; i<=lim; i++)
	{
		if(nprime[i]) continue;
		for(int j=i*i; j<maxn; j+=i) nprime[j]=1;
	}
	for(int i=2; i<maxn; i++) if(!nprime[i]) plist[++tp]=i;
}

int get(int np,int num)
{
	for(int i=np; i<=tp&&plist[i]<=num; i++)
	{
		if(num%plist[i]) continue;
		while(!(num%plist[i]))
		{
			num/=plist[i];
			nlist[i]++;
		}
		return get(i+1,num);
	}
	return np-1;
}

int dfs(int np, int res,int pos,int lim)
{
//	printf("%d %d\n", np, res); system("pause");
	if(np>=lim||plist[np]>pos)
	{
//		printf("ans:%d %d\n", pos, res);
		dp[pos]=max(dp[res], dp[pos]);
//		ans=max(ans,dp[pos]);
//		system("pause");
	}
	for(int i=np; i<=lim; i++)
	{
		if(!nlist[i]) continue;
		dfs(i+1,res,pos,lim);
		for(int j=1; j<=nlist[i]; j++)
		{
			res*=plist[i];
			dfs(i+1,res,pos,lim);
		}
		return 0;
	}
}


#include<iostream>
#include<cstring>
#include<queue>
#include<cmath>
#include<limits>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<map>
#define inf 0x3f3f3f3f
#define ll long long
using namespace std;
int n;
int dp[1000005],a[1000005];
int main()
{
    //freopen( "testin_01.txt", "r", stdin);
    //freopen( "testout_01.txt", "w", stdout);
    //ios::sync_with_stdio(false);
    memset(dp,0,sizeof(dp));

    scanf("%d",&n);
    for (int i=1;i<=n;i++)
         scanf("%d",&a[i]);

    int maxn=-inf;
    for (int i=n;i>=1;i--)
    {
         dp[a[i]]=1;
         for (int j=2;a[i]*j<=a[n];j++)
              dp[a[i]]=max(dp[a[i]],dp[a[i]*j]+1);
         maxn=max(maxn,dp[a[i]]);
    }

    printf("%d",maxn);
    return 0;
}


#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <queue>
using namespace std;
typedef pair<int,int> Pii;
typedef long long LL;
typedef unsigned long long ULL;
#define MST(a,b) memset(a,b,sizeof(a))
#define CLR(a) MST(a,0)
#define Pow2(a) (a*a)

const int maxn=1e6+10;
int N,ans;
int inpt[maxn];
int pos[maxn];
int dp[maxn];
bool vis[maxn];

void DP(int,int);

int main()
{
	scanf("%d\n", &N);
	for(int i=1; i<=N; i++)
	{
		scanf("%d", &inpt[i]);
		pos[inpt[i]]=i;
	}
	for(int i=1; i<=N; i++)
	{
		if(!vis[i]) DP(i,inpt[i]);
		ans=max(ans,dp[i]);
	}
	printf("%d\n", ans);
	return 0;
}

void DP(int np, int num)
{
	vis[np]=1;
	dp[np]=max(dp[np],1);
	for(int i=2; (LL)i*num<maxn; i++)
	{
		if(pos[i*num])
		{
			dp[pos[i*num]]=max(dp[pos[i*num]], dp[np]+1);
			DP(pos[i*num], i*num);
		}
	}
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cstring>
using namespace std;
const int maxn = 1e6 + 4;
const int Maxn = 30;
bool be[maxn];
int num[maxn], dp[maxn];
int n;
int dfs(int num){
	if (~dp[num]) return dp[num];
	int maxv = 1;
	for (int i = 2; i * num < maxn; ++i){
		int to = i * num;
		if (be[to]) maxv = max(dfs(to)+1, maxv);
	}
	return dp[num] = maxv;
}
int main(){
	int i, j, k, kase;
	ios::sync_with_stdio(false);
	cin >> n;
	memset(be, false, sizeof be);
	memset(dp, -1, sizeof dp);
	for (i = 1; i <= n; ++i){
		cin >> num[i];
		be[num[i]] = true;
	}
	int ans = 1;
	for (i = 1; i <= n; ++i){
//		cout << dfs(num[i]) <<  ' ';
		ans = max(ans, dfs(num[i]));
	}
//	cout << endl;
	cout << ans << endl;
	return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<vector>
#include<cctype>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<iomanip>
#include<sstream>
#define ll long long
#define inf 0x3f3f3f3f
#define N 1000000007
using namespace std;
const int maxn= 1e6+10;
int dp[maxn];
int main(){
#ifdef LOCAL
	freopen("C:\\Users\\lanjiaming\\Desktop\\acm\\in.txt","r",stdin);
	//freopen("output.txt","w",stdout);
#endif
ios_base::sync_with_stdio(0);
    int n;
    while(cin>>n)
    {
       memset(dp,0,sizeof(dp));
       int Max = 0;
       for (int i = 0; i < n; i++)
       {
           int x;
           cin>>x;
           dp[x]++;
           Max = max(Max,dp[x]);
           for (int j = x+x; j < maxn; j += x)
           {
               dp[j] = max(dp[j],dp[x]);
           }
       }
       cout<<Max<<endl;
    }
	return 0;
}


#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <queue>
using namespace std;
typedef pair<int,int> Pii;
typedef long long LL;
typedef unsigned long long ULL;
#define MST(a,b) memset(a,b,sizeof(a))
#define CLR(a) MST(a,0)
#define Pow2(a) (a*a)

const int maxn=1e6+10;
int N,ans;
int inpt[maxn];
int pos[maxn];
int dp[maxn];
bool vis[maxn];

void DP(int,int);

int main()
{
	scanf("%d\n", &N);
	for(int i=1; i<=N; i++)
	{
		scanf("%d", &inpt[i]);
		pos[inpt[i]]=i;
	}
	for(int i=1; i<=N; i++)
	{
		if(!vis[i])
		{
			dp[i]=1;
			DP(i,inpt[i]);
		}
		ans=max(ans,dp[i]);
	}
	printf("%d\n", ans);
	return 0;
}

void DP(int np, int num)
{
	vis[np]=1;
	for(int i=2; (LL)i*num<maxn; i++)
	{
		if(pos[i*num])
		{
			dp[pos[i*num]]=max(dp[pos[i*num]], dp[np]+1);
			DP(pos[i*num], i*num);
		}
	}
}


#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <queue>
using namespace std;
typedef pair<int,int> Pii;
typedef long long LL;
typedef unsigned long long ULL;
#define MST(a,b) memset(a,b,sizeof(a))
#define CLR(a) MST(a,0)
#define Pow2(a) (a*a)

const int maxn=1e6+10;
int N,ans;
int inpt[maxn];
bool nprime[maxn];
int tp,plist[maxn];
int nlist[maxn];

map<int,int> dp;

void init();
int get(int,int);
int dfs(int,int,int,int);

int main()
{
	init();
	scanf("%d\n", &N);
	for(int i=1; i<=N; i++) scanf("%d", &inpt[i]);
	for(int i=1; i<=N; i++)
	{
		CLR(nlist);
		int lim=get(1,inpt[i]);//puts("1");
//		for(int j=1; j<=tp; j++) if(nlist[j]) printf("%d %d\n", plist[j], nlist[j]);system("pause");
		dfs(1,1,inpt[i],lim);//puts("2");
		dp[inpt[i]]=dp[inpt[i]]+1;
		//puts("#");
//		printf("%d %d\n", inpt[i], dp[inpt[i]]);
		ans=max(dp[inpt[i]],ans);
	}
	printf("%d\n", ans);
	return 0;
}

void init()
{
	int lim=sqrt(maxn);
	for(int i=2; i<=lim; i++)
	{
		if(nprime[i]) continue;
		for(int j=i*i; j<maxn; j+=i) nprime[j]=1;
	}
	for(int i=2; i<maxn; i++) if(!nprime[i]) plist[++tp]=i;
}

int get(int np,int num)
{
	for(int i=np; i<=tp&&plist[i]<=num; i++)
	{
		if(num%plist[i]) continue;
		while(!(num%plist[i]))
		{
			num/=plist[i];
			nlist[i]++;
		}
		return get(i+1,num);
	}
	return np-1;
}

int dfs(int np, int res,int pos,int lim)
{
//	printf("%d %d\n", np, res); system("pause");
	if(np>=lim||plist[np]>pos)
	{
//		printf("ans:%d %d\n", pos, res);
		dp[pos]=max(dp[res], dp[pos]);
//		ans=max(ans,dp[pos]);
//		system("pause");
	}
	for(int i=np; i<=tp; i++)
	{
		if(!nlist[i]) continue;
		dfs(i+1,res,pos,lim);
		for(int j=1; j<=nlist[i]; j++)
		{
			res*=plist[i];
			dfs(i+1,res,pos,lim);
		}
		return 0;
	}
}


#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <queue>
using namespace std;
typedef pair<int,int> Pii;
typedef long long LL;
typedef unsigned long long ULL;
#define MST(a,b) memset(a,b,sizeof(a))
#define CLR(a) MST(a,0)
#define Pow2(a) (a*a)

const int maxn=1e6+10;
int N,ans;
int inpt[maxn];
int pos[maxn];
int dp[maxn];
bool vis[maxn];

void DP(int,int);

int main()
{
	scanf("%d\n", &N);
	for(int i=1; i<=N; i++)
	{
		scanf("%d", &inpt[i]);
		pos[inpt[i]]=i;
	}
	for(int i=1; i<=N; i++)
	{
		if(!vis[i]) DP(i,inpt[i]);
		ans=max(ans,dp[i]);
	}
	printf("%d\n", ans);
	return 0;
}

void DP(int np, int num)
{
	vis[np]=1;
	dp[np]=max(dp[np],1);
	for(int i=2; (LL)i*num<maxn; i++)
	{
		if(pos[i*num])
		{
			dp[pos[i*num]]=max(dp[pos[i*num]], dp[np]+1);
			DP(pos[i*num], i*num);
			return;
		}
	}
}


//Clique in the Divisibility Gragh
//2015.8.7
//Algorithm:Dp
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
using namespace std;
const int maxn=1000006;
int n,a[maxn],ans;
int f[maxn];
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
       int x;
       cin>>x;
       a[x]++;
    }
    for(int i=maxn;i>=1;i--)
      if(a[i])
      {
         f[i]=1;
         for(int j=2*i;j<=maxn;j+=i)
           if(a[j] && f[i]<f[j]+1)
             f[i]=f[j]+1;
         ans=max(ans,f[i]);
      }
    cout<<ans<<endl;
    return 0;
}


//codeforces 566F Clique in the Divisibility Gragh
//2015.8.7
//Algorithm:Dp
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
using namespace std;
const int maxn=1000006;
int n,a[maxn],ans;
int f[maxn];
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
       int x;
       scanf("%d",x);
       a[x]++;
    }
    for(int i=maxn;i>=1;i--)
      if(a[i])
      {
         f[i]=1;
         for(int j=2*i;j<=maxn;j+=i)
           if(a[j] && f[i]<f[j]+1)
             f[i]=f[j]+1;
         ans=max(ans,f[i]);
      }
    cout<<ans<<endl;
    return 0;
}


//codeforces 566F Clique in the Divisibility Gragh
//2015.8.7
//Algorithm:Dp
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
using namespace std;
const int maxn=1000006;
int n,a[maxn],ans;
int f[maxn];
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
       int x;
       scanf("%d",&x);
       a[x]++;
    }
    for(int i=maxn;i>=1;i--)
      if(a[i])
      {
         f[i]=1;
         for(int j=2*i;j<=maxn;j+=i)
           if(a[j] && f[i]<f[j]+1)
             f[i]=f[j]+1;
         ans=max(ans,f[i]);
      }
    cout<<ans<<endl;
    return 0;
}


//codeforces 566F Clique in the Divisibility Gragh
//2015.8.7
//Algorithm:Dp
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
using namespace std;
const int maxn=1000006;
int n,a[maxn],ans;
int f[maxn];
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
       int x;
       scanf("%d",&x);
       a[x]++;
    }
    for(int i=maxn-6;i>=1;i--)
      if(a[i])
      {
         f[i]=1;
         for(int j=2*i;j<=maxn-6;j+=i)
           if(a[j] && f[i]<f[j]+1)
             f[i]=f[j]+1;
         ans=max(ans,f[i]);
      }
    cout<<ans<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define MOD 1000000007
ll mpow(ll a, ll n,ll mod)
{ll ret=1;ll b=a;while(n) {if(n&1)
    ret=(ret*b)%mod;b=(b*b)%mod;n>>=1;}
return (ll)ret;
}
using namespace std;
#define irr acos(-1.0)
#define mem(x,a) memset(x,a,sizeof(x))
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define N 1000000+3
bool chk[N];
int a[N];
int dp[N];
vector<int> prim;
void sieve()
{
    int i,j;
    for(i=2;i<=sqrt(N);i++)
    {
        if(chk[i]==1)
            continue;
        prim.pb(i);
        for(j=2*i;j<=N;j+=i)
        {
            chk[j]=1;
        }
    }
}
int main()
{
    int i,j,k,n;
    sieve();
    cin>>n;
    for(i=0;i<n;i++)
        {cin>>a[i];dp[a[i]]=1;}
    sort(a,a+n);
    for(i=0;i<n;i++)
        {
            int k=a[i];
            int val=0;
            if(chk[a[i]]==0)
            {
                continue;
            }
            for(j=0;j<prim.size();j++)
            {
                if(k<prim[j])
                    break;
                while(k%prim[j]==0)
                {
                    k/=prim[j];
                    if(a[i]/k>a[i]/2)
                        break;
                    val=max(val,dp[k]);
                    val=max(val,dp[a[i]/k]);
                }
            }
            if(k==1)
            val=max(val,dp[k]);
            dp[a[i]]+=val;
        }
        int max1=-1;
        for(j=0;j<n;j++)
        {
            max1=max(dp[a[j]],max1);
        }
        cout<<max1;
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define MOD 1000000007
ll mpow(ll a, ll n,ll mod)
{ll ret=1;ll b=a;while(n) {if(n&1)
    ret=(ret*b)%mod;b=(b*b)%mod;n>>=1;}
return (ll)ret;
}
using namespace std;
#define irr acos(-1.0)
#define mem(x,a) memset(x,a,sizeof(x))
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define N 1000000+3
bool chk[N];
int a[N];
int dp[N];
vector<int> prim;
void sieve()
{
    int i,j;
    for(i=2;i<=sqrt(N);i++)
    {
        if(chk[i]==1)
            continue;
        prim.pb(i);
        for(j=2*i;j<=N;j+=i)
        {
            chk[j]=1;
        }
    }
}
int main()
{
    int i,j,k,n;
    sieve();
    cin>>n;
    for(i=0;i<n;i++)
        {cin>>a[i];dp[a[i]]=1;}
    sort(a,a+n);
    for(i=0;i<n;i++)
        {
            int k=a[i];
            int val=0;
            if(chk[a[i]]==0)
            {
                continue;
            }
            int f=0;
            for(j=0;j<prim.size();j++)
            {
                if(k<prim[j])
                    break;
                while(k%prim[j]==0)
                {
                    k/=prim[j];
                    if(a[i]/k>a[i]/2)
                        {f=-1;break;}
                    val=max(val,dp[k]);
                    val=max(val,dp[a[i]/k]);
                }
                if(f)
                    break;
            }
            if(k==1)
            val=max(val,dp[k]);
            dp[a[i]]+=val;
        }
        int max1=-1;
        for(j=0;j<n;j++)
        {
            max1=max(dp[a[j]],max1);
        }
        cout<<max1;
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
ll mpow(ll a, ll n,ll mod)
{ll ret=1;ll b=a;while(n) {if(n&1)
    ret=(ret*b)%mod;b=(b*b)%mod;n>>=1;}
return (ll)ret;
}
using namespace std;
#define mem(x,a) memset(x,a,sizeof(x))
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define all(v) v.begin(),v.end()
using namespace std;
#define N (int)(1e6+5)
vector<int> primes;
bool chk[N];
int dp[N],a[N],last[N];
void s(){
    for(int i=2;i<=sqrt(N);i++){
        if(chk[i])
            continue;
        primes.pb(i);
        for(int j=2*i;j<N;j+=i){
            chk[j]=1;
        }
    }
}
void solve(){
    s();
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    mem(last,-1);
    int ans=0;
    sort(a+1,a+1+n);
    for(int i=1;i<=n;i++){
        dp[i]=1;
        if(chk[a[i]]==0){
            int pos=last[a[i]]==-1?0:last[a[i]];
            int pos1=last[1]==-1?0:last[1];
            dp[i]=max(dp[i]+dp[pos],dp[i]+dp[pos1]);
            last[a[i]]=i;
            ans=max(ans,dp[i]);
            continue;
        }
        int x=a[i],val=0;
        int pos=last[a[i]/x]==-1?0:last[a[i]/x];
        int pos1=last[x]==-1?0:last[x];
        val=max(val,max(dp[pos],dp[pos1]));
        for(int j=0;j<primes.size();j++){
            if(chk[x]==0){
               int pos=last[a[i]/x]==-1?0:last[a[i]/x];
               int pos1=last[x]==-1?0:last[x];
               val=max(val,max(dp[pos],dp[pos1]));
               break;
            }
            while(x%primes[j]==0){
                x/=primes[j];
                int pos=last[x]==-1?0:last[x];
                int pos1=last[a[i]/x]==-1?0:last[a[i]/x];
                val=max(val,max(dp[pos],dp[pos1]));
            }
        }
        dp[i]+=val;
        last[a[i]]=i;
        ans=max(ans,dp[i]);
    }
    printf("%d",ans);
}
int main(){
//   ios_base::sync_with_stdio(false);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
ll mpow(ll a, ll n,ll mod)
{ll ret=1;ll b=a;while(n) {if(n&1)
    ret=(ret*b)%mod;b=(b*b)%mod;n>>=1;}
return (ll)ret;
}
using namespace std;
#define mem(x,a) memset(x,a,sizeof(x))
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define all(v) v.begin(),v.end()
using namespace std;
#define N (int)(1e6+5)
int dp[N],a[N];
void solve(){
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        dp[a[i]]=1;
    }
    sort(a+1,a+n+1);
    int ans=0;
    for(int i=1;i<=n;i++){
        int val=0;
        for(int j=1;j<=sqrt(a[i]);j++){
            if(a[i]%j==0){
               int x1=j,x2=a[i]/j;
               if(x2<a[i])
               val=max(val,dp[x2]);
               if(x1<a[i])
               val=max(val,dp[x1]);
            }
        }
        dp[a[i]]+=val;
        ans=max(ans,dp[a[i]]);
    }
    printf("%d",ans);
}
int main(){
//   ios_base::sync_with_stdio(false);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define MOD 1000000007
ll mpow(ll a, ll n,ll mod)
{ll ret=1;ll b=a;while(n) {if(n&1)
    ret=(ret*b)%mod;b=(b*b)%mod;n>>=1;}
return (ll)ret;
}
using namespace std;
#define irr acos(-1.0)
#define mem(x,a) memset(x,a,sizeof(x))
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define N 1000000+3
int dp[N];
int main()
{
    int i,j,k,n,max1=-1;
    cin>>n;
    for(i=0;i<n;i++)
        {cin>>k;dp[k]=1;}
    for(i=N;i>=1;i--)
        {
            int val=0;
           for(j=2*i;j<=N;j+=i)
           {
               val=max(val,dp[j]);
           }
           dp[i]+=val;
           max1=max(dp[i],max1);
        }
        cout<<max1;
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define MOD 1000000007
ll mpow(ll a, ll n,ll mod)
{ll ret=1;ll b=a;while(n) {if(n&1)
    ret=(ret*b)%mod;b=(b*b)%mod;n>>=1;}
return (ll)ret;
}
using namespace std;
#define irr acos(-1.0)
#define mem(x,a) memset(x,a,sizeof(x))
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define N 1000000+3
bool chk[N];
int a[N];
int dp[N];
vector<int> prim;
void sieve()
{
    int i,j;
    for(i=2;i<=sqrt(N);i++)
    {
        if(chk[i]==1)
            continue;
        prim.pb(i);
        for(j=2*i;j<=N;j+=i)
        {
            chk[j]=1;
        }
    }
}
int main()
{
    int i,j,k,n;
    sieve();
    cin>>n;
    for(i=0;i<n;i++)
        {cin>>a[i];dp[a[i]]=1;}
    sort(a,a+n);
    for(i=0;i<n;i++)
        {
            int k=a[i];
            int val=0;
            if(chk[a[i]]==0)
            {
                continue;
            }
            for(j=0;j<prim.size();j++)
            {
                if(k<prim[j])
                    break;
                while(k%prim[j]==0)
                {
                    k/=prim[j];
                    if(k==1)
                        break;
                    val=max(val,dp[k]);
                    val=max(val,dp[a[i]/k]);
                }
            }
            val=max(val,dp[k]);
            dp[a[i]]+=val;
        }
        int max1=-1;
        for(j=0;j<n;j++)
        {
            max1=max(dp[a[j]],max1);
        }
        cout<<max1;
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define MOD 1000000007
ll mpow(ll a, ll n,ll mod)
{ll ret=1;ll b=a;while(n) {if(n&1)
    ret=(ret*b)%mod;b=(b*b)%mod;n>>=1;}
return (ll)ret;
}
using namespace std;
#define irr acos(-1.0)
#define mem(x,a) memset(x,a,sizeof(x))
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define N 1000000+3
bool chk[N];
int a[N];
int dp[N];
int main()
{
    int i,j,k,n;
    cin>>n;
    for(i=0;i<n;i++)
        {cin>>a[i];dp[a[i]]=1;}
    for(i=N;i>=1;i--)
        {
            int val=0;
           for(j=2*i;j<=N;j+=i)
           {
               val=max(val,dp[j]);
           }
           dp[i]+=val;
        }
        int max1=-1;
        for(j=0;j<n;j++)
        {
            max1=max(dp[a[j]],max1);
        }
        cout<<max1;
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define MOD 1000000007
ll mpow(ll a, ll n,ll mod)
{ll ret=1;ll b=a;while(n) {if(n&1)
    ret=(ret*b)%mod;b=(b*b)%mod;n>>=1;}
return (ll)ret;
}
using namespace std;
#define irr acos(-1.0)
#define mem(x,a) memset(x,a,sizeof(x))
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define N 1000000+3
int dp[N];
int main()
{
    int i,j,k,n,max1=-1;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        {scanf("%d",&k);dp[k]=1;}
    for(i=N;i>=1;i--)
        {
            int val=0;
           for(j=2*i;j<=N;j+=i)
           {
               val=max(val,dp[j]);
           }
           dp[i]+=val;
           max1=max(dp[i],max1);
        }
        print("%d",max1);
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
ll mpow(ll a, ll n,ll mod)
{ll ret=1;ll b=a;while(n) {if(n&1)
    ret=(ret*b)%mod;b=(b*b)%mod;n>>=1;}
return (ll)ret;
}
using namespace std;
#define mem(x,a) memset(x,a,sizeof(x))
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define all(v) v.begin(),v.end()
using namespace std;
#define N (int)(1e6+5)
int dp[N];
void solve(){
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        int x;
        scanf("%d",&x);
        dp[x]=1;
    }
    int ans=0;
    for(int i=N-1;i>=1;i--){
        int val=0;
        for(int j=2*i;j<N;j+=i){
            val=max(val,dp[j]);
        }
        dp[i]+=val;
        ans=max(ans,dp[i]);
    }

    printf("%d",ans);
}
int main(){
//   ios_base::sync_with_stdio(false);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define MOD 1000000007
ll mpow(ll a, ll n,ll mod)
{ll ret=1;ll b=a;while(n) {if(n&1)
    ret=(ret*b)%mod;b=(b*b)%mod;n>>=1;}
return (ll)ret;
}
using namespace std;
#define irr acos(-1.0)
#define mem(x,a) memset(x,a,sizeof(x))
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define N 1000000+3
int dp[N];
int main()
{
    int i,j,k,n,max1=-1;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        {scanf("%d",&k);dp[k]=1;}
    for(i=N;i>=1;i--)
        {
            int val=0;
           for(j=2*i;j<=N;j+=i)
           {
               val=max(val,dp[j]);
           }
           dp[i]+=val;
           max1=max(dp[i],max1);
        }
        printf("%d",max1);
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define N 100005
#define NN 1000000009
#define f first
#define s second
#define mp make_pair
#define filein(t) freopen(t, "r", stdin)
#define fileout(t) freopen(t, "w", stdout)
#define ln 1000000009
#define oo 1000000007

using namespace std;

int n, u, dd[N], DP[N];

int main()
{
    ios_base::sync_with_stdio(0);
    //filein("inp.txt");  fileout("out.txt");
    cin >> n;
    for(int i=1; i<=n; i++)
    {
        cin >> u;
        dd[u]++;
    }
    for(int i=1; i<N; i++)
        for(int j=i+i; j<N; j+=i)
            DP[j] = max(DP[j], DP[i] + dd[j]);
    cout << *max_element(DP, DP+N);
}


#include <bits/stdc++.h>
#define ll long long
#define N 1000005
#define NN 1000000009
#define f first
#define s second
#define mp make_pair
#define filein(t) freopen(t, "r", stdin)
#define fileout(t) freopen(t, "w", stdout)
#define ln 1000000009
#define oo 1000000007

using namespace std;

int n, u, dd[N], DP[N], ans;

int main()
{
    ios_base::sync_with_stdio(0);
   // filein("inp.txt");  fileout("out.txt");
    cin >> n;
    for(int i=1; i<=n; i++)
    {
        cin >> u;
        ans = max(ans, DP[u] + 1);
        for(int j=u+u; j<N; j+=u)
            DP[j] = max(DP[j], DP[u]+1);
    }
    cout << ans;
}


#include <bits/stdc++.h>
#define ll long long
#define N 1000005
#define NN 1000000009
#define f first
#define s second
#define mp make_pair
#define filein(t) freopen(t, "r", stdin)
#define fileout(t) freopen(t, "w", stdout)
#define ln 1000000009
#define oo 1000000007

using namespace std;

int n, u, dd[N], DP[N], ans;

int main()
{
    ios_base::sync_with_stdio(0);
    //filein("inp.txt");  fileout("out.txt");
    cin >> n;
    for(int i=1; i<=n; i++)
    {
        cin >> u;
        for(int j=u+u; j<N; j+=u)
            DP[j] = max(DP[j], DP[u]+1);
    }
    cout << *max_element(DP+1, DP+1000001);
}


#include <bits/stdc++.h>
#define ll long long
#define N 1000005
#define NN 1000000009
#define f first
#define s second
#define mp make_pair
#define filein(t) freopen(t, "r", stdin)
#define fileout(t) freopen(t, "w", stdout)
#define ln 1000000009
#define oo 1000000007

using namespace std;

int n, u, dd[N], DP[N], ans;

int main()
{
    ios_base::sync_with_stdio(0);
    //filein("inp.txt");  fileout("out.txt");
    cin >> n;
    for(int i=1; i<=n; i++)
    {
        cin >> u;
        dd[u]++;
    }
    for(int i=1; i<N; i++)
        for(int j=i+i; j<N; j+=i)
            DP[j] = max(DP[j], DP[i] + dd[j]);
    cout << *max_element(DP+1, DP+1000001);
}


#include <bits/stdc++.h>
#define ll long long
#define N 1000005
#define NN 1000000009
#define f first
#define s second
#define mp make_pair
#define filein(t) freopen(t, "r", stdin)
#define fileout(t) freopen(t, "w", stdout)
#define ln 1000000009
#define oo 1000000007

using namespace std;

int n, u, dd[N], DP[N];

int main()
{
    ios_base::sync_with_stdio(0);
    //filein("inp.txt");  fileout("out.txt");
    cin >> n;
    for(int i=1; i<=n; i++)
    {
        cin >> u;
        dd[u]++;
    }
    for(int i=1; i<N; i++)
        for(int j=i+i; j<N; j+=i)
            DP[j] = max(DP[j], DP[i] + dd[j]);
    cout << *max_element(DP, DP+N);
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<vector>
using namespace std;
#pragma comment(linker,"/STACK:102400000,102400000")

#define   fi            first
#define   se            second
#define   sigma_size    26
#define   lson          l,m,rt<<1
#define   rson          m+1,r,rt<<1|1
#define   ll            long long
#define   ull           unsigned long long
#define   mem(x,v)      memset(x,v,sizeof(x))
#define   lowbit(x)     (x&-x)
#define   pii           pair<int,int>
#define   vi            vector<int>
#define   bits(a)       __builtin_popcount(a)
#define   mp            make_pair
#define   pb            push_back
#define   sit           set<int>::iterator
#define   mit           map<int,int>::iterator

/*****************************************************/
inline void RI(int &x) {
      char c;
      while((c=getchar())<'0' || c>'9');
      x=c-'0';
      while((c=getchar())>='0' && c<='9') x=(x<<3)+(x<<1)+c-'0';
 }

inline void Out(int a)
{
    if(a>9) Out(a/10);
    putchar(a%10+'0');
}
/*****************************************************/

// **********************************************
const int     inf   = 0x3f3f3f3f;
const double  pi    = acos(-1.0);
const double  dnf   = 1e18;
const double  eps   = 1e-12;
const ll      mod   = 1000000007;
const int     maxn  = 1000010;
const int     maxk  = 110;
// **********************************************

int n;
int a[maxn],b[maxn];

int main()
{

    while(cin>>n){
        int mmax=0;
        for(int i=1;i<=n;i++){
            scanf("%d",&a[i]);
            mmax=max(mmax,a[i]);
        }
        mem(b,0); b[a[1]]=1;
        int ans=0;
        for(int i=1;i<=n;i++){
            for(int j=a[i]+a[i];j<=mmax;j+=a[i]){
                b[j]=max(b[j],b[a[i]]+1);
            }
            ans=max(ans,b[a[i]]);
        }
        cout<<ans<<endl;
    }
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<vector>
using namespace std;
#pragma comment(linker,"/STACK:102400000,102400000")

#define   fi            first
#define   se            second
#define   sigma_size    26
#define   lson          l,m,rt<<1
#define   rson          m+1,r,rt<<1|1
#define   ll            long long
#define   ull           unsigned long long
#define   mem(x,v)      memset(x,v,sizeof(x))
#define   lowbit(x)     (x&-x)
#define   pii           pair<int,int>
#define   vi            vector<int>
#define   bits(a)       __builtin_popcount(a)
#define   mp            make_pair
#define   pb            push_back
#define   sit           set<int>::iterator
#define   mit           map<int,int>::iterator

/*****************************************************/
inline void RI(int &x) {
      char c;
      while((c=getchar())<'0' || c>'9');
      x=c-'0';
      while((c=getchar())>='0' && c<='9') x=(x<<3)+(x<<1)+c-'0';
 }

inline void Out(int a)
{
    if(a>9) Out(a/10);
    putchar(a%10+'0');
}
/*****************************************************/

// **********************************************
const int     inf   = 0x3f3f3f3f;
const double  pi    = acos(-1.0);
const double  dnf   = 1e18;
const double  eps   = 1e-12;
const ll      mod   = 1000000007;
const int     maxn  = 100010;
const int     maxk  = 110;
// **********************************************

int n;
int a[maxn],b[maxn];

int main()
{

    while(cin>>n){
        int mmax=0;
        for(int i=1;i<=n;i++){
            scanf("%d",&a[i]);
            mmax=max(mmax,a[i]);
        }
        mem(b,0); b[a[1]]=1;
        int ans=0;
        for(int i=1;i<=n;i++){
            for(int j=a[i]+a[i];j<=mmax;j+=a[i]){
                b[j]=max(b[j],b[a[i]]+1);
            }
            ans=max(ans,b[a[i]]);
        }
        cout<<ans<<endl;
    }
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<vector>
using namespace std;
#pragma comment(linker,"/STACK:102400000,102400000")

#define   fi            first
#define   se            second
#define   sigma_size    26
#define   lson          l,m,rt<<1
#define   rson          m+1,r,rt<<1|1
#define   ll            long long
#define   ull           unsigned long long
#define   mem(x,v)      memset(x,v,sizeof(x))
#define   lowbit(x)     (x&-x)
#define   pii           pair<int,int>
#define   vi            vector<int>
#define   bits(a)       __builtin_popcount(a)
#define   mp            make_pair
#define   pb            push_back
#define   sit           set<int>::iterator
#define   mit           map<int,int>::iterator

/*****************************************************/
inline void RI(int &x) {
      char c;
      while((c=getchar())<'0' || c>'9');
      x=c-'0';
      while((c=getchar())>='0' && c<='9') x=(x<<3)+(x<<1)+c-'0';
 }

inline void Out(int a)
{
    if(a>9) Out(a/10);
    putchar(a%10+'0');
}
/*****************************************************/

// **********************************************
const int     inf   = 0x3f3f3f3f;
const double  pi    = acos(-1.0);
const double  dnf   = 1e18;
const double  eps   = 1e-12;
const ll      mod   = 1000000007;
const int     maxn  = 1000010;
const int     maxk  = 110;
// **********************************************

int n;
int a[maxn],b[maxn];

int main()
{

    while(cin>>n){
        int mmax=0;
        for(int i=1;i<=n;i++){
            scanf("%d",&a[i]);
            mmax=max(mmax,a[i]);
        }
        mem(b,0);
        int ans=0;
        for(int i=1;i<=n;i++){
            b[a[i]]++;
            for(int j=a[i]+a[i];j<=mmax;j+=a[i]){
                b[j]=max(b[j],b[a[i]]);
            }
            ans=max(ans,b[a[i]]);
        }
        cout<<ans<<endl;
    }
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<vector>
using namespace std;
#pragma comment(linker,"/STACK:102400000,102400000")

#define   fi            first
#define   se            second
#define   sigma_size    26
#define   lson          l,m,rt<<1
#define   rson          m+1,r,rt<<1|1
#define   ll            long long
#define   ull           unsigned long long
#define   mem(x,v)      memset(x,v,sizeof(x))
#define   lowbit(x)     (x&-x)
#define   pii           pair<int,int>
#define   vi            vector<int>
#define   bits(a)       __builtin_popcount(a)
#define   mp            make_pair
#define   pb            push_back
#define   sit           set<int>::iterator
#define   mit           map<int,int>::iterator

/*****************************************************/
inline void RI(int &x) {
      char c;
      while((c=getchar())<'0' || c>'9');
      x=c-'0';
      while((c=getchar())>='0' && c<='9') x=(x<<3)+(x<<1)+c-'0';
 }

inline void Out(int a)
{
    if(a>9) Out(a/10);
    putchar(a%10+'0');
}
/*****************************************************/

// **********************************************
const int     inf   = 0x3f3f3f3f;
const double  pi    = acos(-1.0);
const double  dnf   = 1e18;
const double  eps   = 1e-12;
const ll      mod   = 1000000007;
const int     maxn  = 1000010;
const int     maxk  = 110;
// **********************************************

vi factor[maxn];
int n;
int a[maxn],b[maxn];

int main()
{
    for(int i=1;i<maxn;i++){
        for(int j=i+i;j<maxn;j+=i){
            factor[j].pb(i);
        }
    }
    while(cin>>n){
        for(int i=1;i<=n;i++) scanf("%d",&a[i]);
        mem(b,0);
        int ans=0;
        for(int i=1;i<=n;i++){
            for(int j=0;j<factor[i].size();j++){
                b[i]=max(b[i],b[factor[i][j]]+1);
            }
            ans=max(ans,b[i]);
        }
        cout<<ans<<endl;
    }
}


#include<iostream>
#include<list>
#include<string>
#include<cstring>
#include<sstream>
#include<cctype>
#include<string.h>
#include<algorithm>
#include<cmath>
#include<stack>
#include<fstream>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
#include<queue>
using namespace std;

#define LL long long int
#define uLL unsigned long long int

#define S(a) scanf("%d",&a)
#define S2(a,b) scanf("%d%d",&a,&b)
#define S3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define SLL(a) scanf("%lld",&a)
#define SLL2(a,b) scanf("%lld%lld",&a,&b)
#define SLL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define SC(a) scanf("%c",&a)
#define P(a) printf("%d",a)
#define PS(a) printf("%s",a)
#define PLL(a) printf("%lld",a)
#define PCASE(kk) printf("Case %d: ",kk++)
#define PCASENL(kk) printf("Case %d:\n",kk++)
#define NL puts("")

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define pi (2.0*acos(0.0))
#define pii pair<int,int>

template<typename T>inline T POW(T B,T P)
{
    if(P==0) return 1;
    if(P&1) return B*POW(B,P-1);
    else return SQR(POW(B,P/2));
}
template <typename T>inline T ModInv (T b,T m)
{
    return BigMod(b,m-2,m);
}
template<typename T>inline T ABS(T a)
{
    if(a<0)return -a;
    else return a;
}
template<typename T>inline T gcd(T a,T b)
{
    if(a<0)return gcd(-a,b);
    if(b<0)return gcd(a,-b);
    return (b==0)?a:gcd(b,a%b);
}
template<typename T>inline T lcm(T a,T b)
{
    if(a<0)return lcm(-a,b);
    if(b<0)return lcm(a,-b);
    return a*(b/gcd(a,b));
}
template <class T> inline T BMOD(T p,T e,T m)
{
    T ret=1;
    while(e)
    {
        if(e&1) ret=(ret*p)%m;
        p=(p*p)%m;
        e>>=1;
    }
    return (T)ret;
}

//for(__typeof(pp.begin()) i=pp.begin(); i!=pp.end(); i++ )

//knight and king move....

//int Dx[]={-2,-1,1,2,1,2,-2,-1};
//int Dy[]={-1,-2,2,1,-2,-1,1,2};
//int dx[]={-1,1,0,0};
//int dy[]={0,0,-1,1};
//int dx[]= {-1,-1,0,0,1,1};
//int dy[]= {-1,0,-1,1,0,1};
//////////////////////////////////////////////////

int dp[1100000],arr[1100000],n,cnt[1100000];
vector<int>v;

int main()
{
     freopen ("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    int mx=-1;
    S(n);
    for(int i=1; i<=n; i++)
    {
        S(arr[i]);
        if(cnt[arr[i]]==0)v.pb(arr[i]);
        cnt[arr[i]]=1;
        dp[arr[i]]+=1;
        mx=max(mx,arr[i]);

    }

    sort(v.begin(),v.end());

    int ans=0;
    for(int i=0; i<v.size(); i++)
    {
        int num=v[i];
        if(num>1000)break;
        for(int j=2; num<=mx; j++)
        {
            num=num*j;
            if(cnt[num]==1)
            {
                dp[num]=max(dp[num/j]+1,dp[num]);
//                cout<<num<<" "<<dp[num/j]<<" "<<dp[num]<<endl;
            }
        }
        ans=max(ans,dp[v[i]]);
    }
//    for(int i=0;i<v.size();i++)ans=max(ans,dp[v[i]]);
    P(ans),NL;
    return 0;
}


#include<iostream>
#include<list>
#include<string>
#include<cstring>
#include<sstream>
#include<cctype>
#include<string.h>
#include<algorithm>
#include<cmath>
#include<stack>
#include<fstream>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
#include<queue>
using namespace std;

#define LL long long int
#define uLL unsigned long long int

#define S(a) scanf("%d",&a)
#define S2(a,b) scanf("%d%d",&a,&b)
#define S3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define SLL(a) scanf("%lld",&a)
#define SLL2(a,b) scanf("%lld%lld",&a,&b)
#define SLL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define SC(a) scanf("%c",&a)
#define P(a) printf("%d",a)
#define PS(a) printf("%s",a)
#define PLL(a) printf("%lld",a)
#define PCASE(kk) printf("Case %d: ",kk++)
#define PCASENL(kk) printf("Case %d:\n",kk++)
#define NL puts("")

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define pi (2.0*acos(0.0))
#define pii pair<int,int>

template<typename T>inline T POW(T B,T P)
{
    if(P==0) return 1;
    if(P&1) return B*POW(B,P-1);
    else return SQR(POW(B,P/2));
}
template <typename T>inline T ModInv (T b,T m)
{
    return BigMod(b,m-2,m);
}
template<typename T>inline T ABS(T a)
{
    if(a<0)return -a;
    else return a;
}
template<typename T>inline T gcd(T a,T b)
{
    if(a<0)return gcd(-a,b);
    if(b<0)return gcd(a,-b);
    return (b==0)?a:gcd(b,a%b);
}
template<typename T>inline T lcm(T a,T b)
{
    if(a<0)return lcm(-a,b);
    if(b<0)return lcm(a,-b);
    return a*(b/gcd(a,b));
}
template <class T> inline T BMOD(T p,T e,T m)
{
    T ret=1;
    while(e)
    {
        if(e&1) ret=(ret*p)%m;
        p=(p*p)%m;
        e>>=1;
    }
    return (T)ret;
}

//for(__typeof(pp.begin()) i=pp.begin(); i!=pp.end(); i++ )

//knight and king move....

//int Dx[]={-2,-1,1,2,1,2,-2,-1};
//int Dy[]={-1,-2,2,1,-2,-1,1,2};
//int dx[]={-1,1,0,0};
//int dy[]={0,0,-1,1};
//int dx[]= {-1,-1,0,0,1,1};
//int dy[]= {-1,0,-1,1,0,1};
//////////////////////////////////////////////////

int dp[1100000],arr[1100000],n,cnt[1100000];
vector<int>v;

int main()
{
//     freopen ("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
    int mx=-1;
    S(n);
    for(int i=1; i<=n; i++)
    {
        S(arr[i]);
        if(cnt[arr[i]]==0)v.pb(arr[i]);
        cnt[arr[i]]=1;
        dp[arr[i]]+=1;
        mx=max(mx,arr[i]);

    }

    sort(v.begin(),v.end());

    int ans=0;
    for(int i=0; i<v.size(); i++)
    {
        int num=v[i];
//        if(num>mx/2)break;
        for(int j=2; num<=mx; j++)
        {
            num=num*j;
            if(num>mx)break;
            if(cnt[num]==1)
            {
                dp[num]=max(dp[num/j]+1,dp[num]);
//                cout<<num<<" "<<dp[num/j]<<" "<<dp[num]<<endl;
            }
        }
        ans=max(ans,dp[v[i]]);
    }
//    for(int i=0;i<v.size();i++)ans=max(ans,dp[v[i]]);
    P(ans),NL;
    return 0;
}


#include<iostream>
#include<list>
#include<string>
#include<cstring>
#include<sstream>
#include<cctype>
#include<string.h>
#include<algorithm>
#include<cmath>
#include<stack>
#include<fstream>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
#include<queue>
using namespace std;

#define LL long long int
#define uLL unsigned long long int

#define S(a) scanf("%d",&a)
#define S2(a,b) scanf("%d%d",&a,&b)
#define S3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define SLL(a) scanf("%lld",&a)
#define SLL2(a,b) scanf("%lld%lld",&a,&b)
#define SLL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define SC(a) scanf("%c",&a)
#define P(a) printf("%d",a)
#define PS(a) printf("%s",a)
#define PLL(a) printf("%lld",a)
#define PCASE(kk) printf("Case %d: ",kk++)
#define PCASENL(kk) printf("Case %d:\n",kk++)
#define NL puts("")

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define pi (2.0*acos(0.0))
#define pii pair<int,int>

template<typename T>inline T POW(T B,T P)
{
    if(P==0) return 1;
    if(P&1) return B*POW(B,P-1);
    else return SQR(POW(B,P/2));
}
template <typename T>inline T ModInv (T b,T m)
{
    return BigMod(b,m-2,m);
}
template<typename T>inline T ABS(T a)
{
    if(a<0)return -a;
    else return a;
}
template<typename T>inline T gcd(T a,T b)
{
    if(a<0)return gcd(-a,b);
    if(b<0)return gcd(a,-b);
    return (b==0)?a:gcd(b,a%b);
}
template<typename T>inline T lcm(T a,T b)
{
    if(a<0)return lcm(-a,b);
    if(b<0)return lcm(a,-b);
    return a*(b/gcd(a,b));
}
template <class T> inline T BMOD(T p,T e,T m)
{
    T ret=1;
    while(e)
    {
        if(e&1) ret=(ret*p)%m;
        p=(p*p)%m;
        e>>=1;
    }
    return (T)ret;
}

//for(__typeof(pp.begin()) i=pp.begin(); i!=pp.end(); i++ )

//knight and king move....

//int Dx[]={-2,-1,1,2,1,2,-2,-1};
//int Dy[]={-1,-2,2,1,-2,-1,1,2};
//int dx[]={-1,1,0,0};
//int dy[]={0,0,-1,1};
//int dx[]= {-1,-1,0,0,1,1};
//int dy[]= {-1,0,-1,1,0,1};
//////////////////////////////////////////////////

int dp[1100000],arr[1100000],n,cnt[1100000];
vector<int>v;

int main()
{
//     freopen ("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
    int mx=-1;
    S(n);
    for(int i=1; i<=n; i++)
    {
        S(arr[i]);
        if(cnt[arr[i]]==0)v.pb(arr[i]);
        cnt[arr[i]]=1;
        dp[arr[i]]=1;
        mx=max(mx,arr[i]);

    }

    sort(v.begin(),v.end());

    int ans=0;
    for(int i=0; i<v.size(); i++)
    {
        int num=v[i];
        if(num>1000)break;
        for(int j=2; num<=mx; j++)
        {
            num=num*j;
            if(cnt[num]==1)
            {
                dp[num]=max(dp[num/j]+1,dp[num]);
//                cout<<num<<" "<<dp[num/j]<<" "<<dp[num]<<endl;
            }
        }
        ans=max(ans,dp[v[i]]);
    }
//    for(int i=0;i<v.size();i++)ans=max(ans,dp[v[i]]);
    P(ans),NL;
    return 0;
}


#include<iostream>
#include<list>
#include<string>
#include<cstring>
#include<sstream>
#include<cctype>
#include<string.h>
#include<algorithm>
#include<cmath>
#include<stack>
#include<fstream>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
#include<queue>
using namespace std;

#define LL long long int
#define uLL unsigned long long int

#define S(a) scanf("%d",&a)
#define S2(a,b) scanf("%d%d",&a,&b)
#define S3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define SLL(a) scanf("%lld",&a)
#define SLL2(a,b) scanf("%lld%lld",&a,&b)
#define SLL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define SC(a) scanf("%c",&a)
#define P(a) printf("%d",a)
#define PS(a) printf("%s",a)
#define PLL(a) printf("%lld",a)
#define PCASE(kk) printf("Case %d: ",kk++)
#define PCASENL(kk) printf("Case %d:\n",kk++)
#define NL puts("")

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define pi (2.0*acos(0.0))
#define pii pair<int,int>

template<typename T>inline T POW(T B,T P)
{
    if(P==0) return 1;
    if(P&1) return B*POW(B,P-1);
    else return SQR(POW(B,P/2));
}
template <typename T>inline T ModInv (T b,T m)
{
    return BigMod(b,m-2,m);
}
template<typename T>inline T ABS(T a)
{
    if(a<0)return -a;
    else return a;
}
template<typename T>inline T gcd(T a,T b)
{
    if(a<0)return gcd(-a,b);
    if(b<0)return gcd(a,-b);
    return (b==0)?a:gcd(b,a%b);
}
template<typename T>inline T lcm(T a,T b)
{
    if(a<0)return lcm(-a,b);
    if(b<0)return lcm(a,-b);
    return a*(b/gcd(a,b));
}
template <class T> inline T BMOD(T p,T e,T m)
{
    T ret=1;
    while(e)
    {
        if(e&1) ret=(ret*p)%m;
        p=(p*p)%m;
        e>>=1;
    }
    return (T)ret;
}

//for(__typeof(pp.begin()) i=pp.begin(); i!=pp.end(); i++ )

//knight and king move....

//int Dx[]={-2,-1,1,2,1,2,-2,-1};
//int Dy[]={-1,-2,2,1,-2,-1,1,2};
//int dx[]={-1,1,0,0};
//int dy[]={0,0,-1,1};
//int dx[]= {-1,-1,0,0,1,1};
//int dy[]= {-1,0,-1,1,0,1};
//////////////////////////////////////////////////

int dp[1100000],arr[1100000],n,cnt[1100000];

int main()
{
    int mx=-1;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>arr[i];
        cnt[arr[i]]=1;
        dp[arr[i]]=1;
        mx=max(mx,arr[i]);
    }

    sort(arr+1,arr+n+1);

    for(int i=1;i<=n;i++)
    {
        int num=arr[i];
        for(int j=2;num<=mx;j++)
        {
            num=num*j;
            if(cnt[num]==1)
            {
                dp[num]=max(dp[num/j]+1,dp[num]);
//                cout<<num<<" "<<dp[num/j]<<" "<<dp[num]<<endl;
            }
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++)ans=max(ans,dp[arr[i]]);
    cout<<ans<<endl;
    return 0;
}


#include<iostream>
#include<list>
#include<string>
#include<cstring>
#include<sstream>
#include<cctype>
#include<string.h>
#include<algorithm>
#include<cmath>
#include<stack>
#include<fstream>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
#include<queue>
using namespace std;

#define LL long long int
#define uLL unsigned long long int

#define S(a) scanf("%d",&a)
#define S2(a,b) scanf("%d%d",&a,&b)
#define S3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define SLL(a) scanf("%lld",&a)
#define SLL2(a,b) scanf("%lld%lld",&a,&b)
#define SLL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define SC(a) scanf("%c",&a)
#define P(a) printf("%d",a)
#define PS(a) printf("%s",a)
#define PLL(a) printf("%lld",a)
#define PCASE(kk) printf("Case %d: ",kk++)
#define PCASENL(kk) printf("Case %d:\n",kk++)
#define NL puts("")

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define pi (2.0*acos(0.0))
#define pii pair<int,int>

template<typename T>inline T POW(T B,T P)
{
    if(P==0) return 1;
    if(P&1) return B*POW(B,P-1);
    else return SQR(POW(B,P/2));
}
template <typename T>inline T ModInv (T b,T m)
{
    return BigMod(b,m-2,m);
}
template<typename T>inline T ABS(T a)
{
    if(a<0)return -a;
    else return a;
}
template<typename T>inline T gcd(T a,T b)
{
    if(a<0)return gcd(-a,b);
    if(b<0)return gcd(a,-b);
    return (b==0)?a:gcd(b,a%b);
}
template<typename T>inline T lcm(T a,T b)
{
    if(a<0)return lcm(-a,b);
    if(b<0)return lcm(a,-b);
    return a*(b/gcd(a,b));
}
template <class T> inline T BMOD(T p,T e,T m)
{
    T ret=1;
    while(e)
    {
        if(e&1) ret=(ret*p)%m;
        p=(p*p)%m;
        e>>=1;
    }
    return (T)ret;
}

//for(__typeof(pp.begin()) i=pp.begin(); i!=pp.end(); i++ )

//knight and king move....

//int Dx[]={-2,-1,1,2,1,2,-2,-1};
//int Dy[]={-1,-2,2,1,-2,-1,1,2};
//int dx[]={-1,1,0,0};
//int dy[]={0,0,-1,1};
//int dx[]= {-1,-1,0,0,1,1};
//int dy[]= {-1,0,-1,1,0,1};
//////////////////////////////////////////////////

int dp[1100000],arr[1100000],n,cnt[1100000];
vector<int>v;

int main()
{
    int mx=-1;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>arr[i];
        if(cnt[arr[i]]==0)v.pb(arr[i]);
        cnt[arr[i]]=1;
        dp[arr[i]]=1;
        mx=max(mx,arr[i]);

    }

    sort(v.begin(),v.end());

    int ans=0;
    for(int i=0;i<v.size();i++)
    {
        int num=v[i];
        for(int j=2;num<=mx;j++)
        {
            num=num*j;
            if(cnt[num]==1)
            {
                dp[num]=max(dp[num/j]+1,dp[num]);
//                cout<<num<<" "<<dp[num/j]<<" "<<dp[num]<<endl;
            }
        }
        ans=max(ans,dp[v[i]]);
    }
//    for(int i=0;i<v.size();i++)ans=max(ans,dp[v[i]]);
    cout<<ans<<endl;
    return 0;
}


#include<iostream>
#include<list>
#include<string>
#include<cstring>
#include<sstream>
#include<cctype>
#include<string.h>
#include<algorithm>
#include<cmath>
#include<stack>
#include<fstream>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
#include<queue>
using namespace std;

#define LL long long int
#define uLL unsigned long long int

#define S(a) scanf("%d",&a)
#define S2(a,b) scanf("%d%d",&a,&b)
#define S3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define SLL(a) scanf("%lld",&a)
#define SLL2(a,b) scanf("%lld%lld",&a,&b)
#define SLL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define SC(a) scanf("%c",&a)
#define P(a) printf("%d",a)
#define PS(a) printf("%s",a)
#define PLL(a) printf("%lld",a)
#define PCASE(kk) printf("Case %d: ",kk++)
#define PCASENL(kk) printf("Case %d:\n",kk++)
#define NL puts("")

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define pi (2.0*acos(0.0))
#define pii pair<int,int>

template<typename T>inline T POW(T B,T P)
{
    if(P==0) return 1;
    if(P&1) return B*POW(B,P-1);
    else return SQR(POW(B,P/2));
}
template <typename T>inline T ModInv (T b,T m)
{
    return BigMod(b,m-2,m);
}
template<typename T>inline T ABS(T a)
{
    if(a<0)return -a;
    else return a;
}
template<typename T>inline T gcd(T a,T b)
{
    if(a<0)return gcd(-a,b);
    if(b<0)return gcd(a,-b);
    return (b==0)?a:gcd(b,a%b);
}
template<typename T>inline T lcm(T a,T b)
{
    if(a<0)return lcm(-a,b);
    if(b<0)return lcm(a,-b);
    return a*(b/gcd(a,b));
}
template <class T> inline T BMOD(T p,T e,T m)
{
    T ret=1;
    while(e)
    {
        if(e&1) ret=(ret*p)%m;
        p=(p*p)%m;
        e>>=1;
    }
    return (T)ret;
}

//for(__typeof(pp.begin()) i=pp.begin(); i!=pp.end(); i++ )

//knight and king move....

//int Dx[]={-2,-1,1,2,1,2,-2,-1};
//int Dy[]={-1,-2,2,1,-2,-1,1,2};
//int dx[]={-1,1,0,0};
//int dy[]={0,0,-1,1};
//int dx[]= {-1,-1,0,0,1,1};
//int dy[]= {-1,0,-1,1,0,1};
//////////////////////////////////////////////////

int dp[1100000],arr[1100000],n,cnt[1100000];
vector<int>v;

int main()
{
//     freopen ("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
    int mx=-1;
    S(n);
    for(int i=1; i<=n; i++)
    {
        S(arr[i]);
        if(cnt[arr[i]]==0)v.pb(arr[i]);
        cnt[arr[i]]=1;
        dp[arr[i]]=1;
        mx=max(mx,arr[i]);

    }

//    sort(v.begin(),v.end());

    int ans=0;
    for(int i=0; i<v.size(); i++)
    {
        int num=v[i];
//        if(num>mx/2)break;
        for(int j=2; num<=1000000; j++)
        {
            num=v[i]*j;
            if(num>mx)break;
            if(cnt[num]==1)
            {
                dp[num]=max(dp[num/j]+1,dp[num]);
//                cout<<num<<" "<<dp[num/j]<<" "<<dp[num]<<endl;
            }
        }
        ans=max(ans,dp[v[i]]);
    }
//    for(int i=0;i<v.size();i++)ans=max(ans,dp[v[i]]);
    P(ans),NL;
    return 0;
}
//10
//2 6 9 13 39 42 49 50 65 100


#include<iostream>
#include<list>
#include<string>
#include<cstring>
#include<sstream>
#include<cctype>
#include<string.h>
#include<algorithm>
#include<cmath>
#include<stack>
#include<fstream>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
#include<queue>
using namespace std;

#define LL long long int
#define uLL unsigned long long int

#define S(a) scanf("%d",&a)
#define S2(a,b) scanf("%d%d",&a,&b)
#define S3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define SLL(a) scanf("%lld",&a)
#define SLL2(a,b) scanf("%lld%lld",&a,&b)
#define SLL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define SC(a) scanf("%c",&a)
#define P(a) printf("%d",a)
#define PS(a) printf("%s",a)
#define PLL(a) printf("%lld",a)
#define PCASE(kk) printf("Case %d: ",kk++)
#define PCASENL(kk) printf("Case %d:\n",kk++)
#define NL puts("")

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define pi (2.0*acos(0.0))
#define pii pair<int,int>

template<typename T>inline T POW(T B,T P)
{
    if(P==0) return 1;
    if(P&1) return B*POW(B,P-1);
    else return SQR(POW(B,P/2));
}
template <typename T>inline T ModInv (T b,T m)
{
    return BigMod(b,m-2,m);
}
template<typename T>inline T ABS(T a)
{
    if(a<0)return -a;
    else return a;
}
template<typename T>inline T gcd(T a,T b)
{
    if(a<0)return gcd(-a,b);
    if(b<0)return gcd(a,-b);
    return (b==0)?a:gcd(b,a%b);
}
template<typename T>inline T lcm(T a,T b)
{
    if(a<0)return lcm(-a,b);
    if(b<0)return lcm(a,-b);
    return a*(b/gcd(a,b));
}
template <class T> inline T BMOD(T p,T e,T m)
{
    T ret=1;
    while(e)
    {
        if(e&1) ret=(ret*p)%m;
        p=(p*p)%m;
        e>>=1;
    }
    return (T)ret;
}

//for(__typeof(pp.begin()) i=pp.begin(); i!=pp.end(); i++ )

//knight and king move....

//int Dx[]={-2,-1,1,2,1,2,-2,-1};
//int Dy[]={-1,-2,2,1,-2,-1,1,2};
//int dx[]={-1,1,0,0};
//int dy[]={0,0,-1,1};
//int dx[]= {-1,-1,0,0,1,1};
//int dy[]= {-1,0,-1,1,0,1};
//////////////////////////////////////////////////

int dp[1100000],arr[1100000],n,cnt[1100000];
vector<int>v;

int main()
{
//     freopen ("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
    int mx=-1;
    S(n);
    for(int i=1; i<=n; i++)
    {
        S(arr[i]);
        if(cnt[arr[i]]==0)v.pb(arr[i]);
        cnt[arr[i]]=1;
        dp[arr[i]]=1;
        mx=max(mx,arr[i]);

    }

    sort(v.begin(),v.end());

    int ans=0;
    for(int i=0; i<v.size(); i++)
    {
        int num=v[i];
//        if(num>mx/2)break;
        for(int j=2; num<=mx; j++)
        {
            num=num*j;
            if(num>mx)break;
            if(cnt[num]==1)
            {
                dp[num]=max(dp[num/j]+1,dp[num]);
//                cout<<num<<" "<<dp[num/j]<<" "<<dp[num]<<endl;
            }
        }
        ans=max(ans,dp[v[i]]);
    }
//    for(int i=0;i<v.size();i++)ans=max(ans,dp[v[i]]);
    P(ans),NL;
    return 0;
}


#include<iostream>
#include<list>
#include<string>
#include<cstring>
#include<sstream>
#include<cctype>
#include<string.h>
#include<algorithm>
#include<cmath>
#include<stack>
#include<fstream>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
#include<queue>
using namespace std;

#define LL long long int
#define uLL unsigned long long int

#define S(a) scanf("%d",&a)
#define S2(a,b) scanf("%d%d",&a,&b)
#define S3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define SLL(a) scanf("%lld",&a)
#define SLL2(a,b) scanf("%lld%lld",&a,&b)
#define SLL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define SC(a) scanf("%c",&a)
#define P(a) printf("%d",a)
#define PS(a) printf("%s",a)
#define PLL(a) printf("%lld",a)
#define PCASE(kk) printf("Case %d: ",kk++)
#define PCASENL(kk) printf("Case %d:\n",kk++)
#define NL puts("")

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define pi (2.0*acos(0.0))
#define pii pair<int,int>

template<typename T>inline T POW(T B,T P)
{
    if(P==0) return 1;
    if(P&1) return B*POW(B,P-1);
    else return SQR(POW(B,P/2));
}
template <typename T>inline T ModInv (T b,T m)
{
    return BigMod(b,m-2,m);
}
template<typename T>inline T ABS(T a)
{
    if(a<0)return -a;
    else return a;
}
template<typename T>inline T gcd(T a,T b)
{
    if(a<0)return gcd(-a,b);
    if(b<0)return gcd(a,-b);
    return (b==0)?a:gcd(b,a%b);
}
template<typename T>inline T lcm(T a,T b)
{
    if(a<0)return lcm(-a,b);
    if(b<0)return lcm(a,-b);
    return a*(b/gcd(a,b));
}
template <class T> inline T BMOD(T p,T e,T m)
{
    T ret=1;
    while(e)
    {
        if(e&1) ret=(ret*p)%m;
        p=(p*p)%m;
        e>>=1;
    }
    return (T)ret;
}

//for(__typeof(pp.begin()) i=pp.begin(); i!=pp.end(); i++ )

//knight and king move....

//int Dx[]={-2,-1,1,2,1,2,-2,-1};
//int Dy[]={-1,-2,2,1,-2,-1,1,2};
//int dx[]={-1,1,0,0};
//int dy[]={0,0,-1,1};
//int dx[]= {-1,-1,0,0,1,1};
//int dy[]= {-1,0,-1,1,0,1};
//////////////////////////////////////////////////

int dp[1100000],arr[1100000],n,cnt[1100000];
vector<int>v;

int main()
{
//     freopen ("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
    int mx=-1;
    S(n);
    for(int i=1; i<=n; i++)
    {
        S(arr[i]);
        if(cnt[arr[i]]==0)v.pb(arr[i]);
        cnt[arr[i]]=1;
        dp[arr[i]]+=1;
        mx=max(mx,arr[i]);

    }

    sort(v.begin(),v.end());

    int ans=0;
    for(int i=0; i<v.size(); i++)
    {
        int num=v[i];
        if(num>1000)break;
        for(int j=2; num<=mx; j++)
        {
            num=num*j;
            if(cnt[num]==1)
            {
                dp[num]=max(dp[num/j]+1,dp[num]);
//                cout<<num<<" "<<dp[num/j]<<" "<<dp[num]<<endl;
            }
        }
        ans=max(ans,dp[v[i]]);
    }
//    for(int i=0;i<v.size();i++)ans=max(ans,dp[v[i]]);
    P(ans),NL;
    return 0;
}


#include<iostream>
#include<list>
#include<string>
#include<cstring>
#include<sstream>
#include<cctype>
#include<string.h>
#include<algorithm>
#include<cmath>
#include<stack>
#include<fstream>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
#include<queue>
using namespace std;

#define LL long long int
#define uLL unsigned long long int

#define S(a) scanf("%d",&a)
#define S2(a,b) scanf("%d%d",&a,&b)
#define S3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define SLL(a) scanf("%lld",&a)
#define SLL2(a,b) scanf("%lld%lld",&a,&b)
#define SLL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define SC(a) scanf("%c",&a)
#define P(a) printf("%d",a)
#define PS(a) printf("%s",a)
#define PLL(a) printf("%lld",a)
#define PCASE(kk) printf("Case %d: ",kk++)
#define PCASENL(kk) printf("Case %d:\n",kk++)
#define NL puts("")

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define pi (2.0*acos(0.0))
#define pii pair<int,int>

template<typename T>inline T POW(T B,T P)
{
    if(P==0) return 1;
    if(P&1) return B*POW(B,P-1);
    else return SQR(POW(B,P/2));
}
template <typename T>inline T ModInv (T b,T m)
{
    return BigMod(b,m-2,m);
}
template<typename T>inline T ABS(T a)
{
    if(a<0)return -a;
    else return a;
}
template<typename T>inline T gcd(T a,T b)
{
    if(a<0)return gcd(-a,b);
    if(b<0)return gcd(a,-b);
    return (b==0)?a:gcd(b,a%b);
}
template<typename T>inline T lcm(T a,T b)
{
    if(a<0)return lcm(-a,b);
    if(b<0)return lcm(a,-b);
    return a*(b/gcd(a,b));
}
template <class T> inline T BMOD(T p,T e,T m)
{
    T ret=1;
    while(e)
    {
        if(e&1) ret=(ret*p)%m;
        p=(p*p)%m;
        e>>=1;
    }
    return (T)ret;
}

//for(__typeof(pp.begin()) i=pp.begin(); i!=pp.end(); i++ )

//knight and king move....

//int Dx[]={-2,-1,1,2,1,2,-2,-1};
//int Dy[]={-1,-2,2,1,-2,-1,1,2};
//int dx[]={-1,1,0,0};
//int dy[]={0,0,-1,1};
//int dx[]= {-1,-1,0,0,1,1};
//int dy[]= {-1,0,-1,1,0,1};
//////////////////////////////////////////////////

int dp[1100000],arr[1100000],n,cnt[1100000];
vector<int>v;

int main()
{
//     freopen ("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
    int mx=-1;
    S(n);
    for(int i=1; i<=n; i++)
    {
        S(arr[i]);
        if(cnt[arr[i]]==0)v.pb(arr[i]);
        cnt[arr[i]]=1;
        dp[arr[i]]=1;
        mx=max(mx,arr[i]);

    }

    sort(v.begin(),v.end());

    int ans=0;
    for(int i=0; i<v.size(); i++)
    {
        int num=v[i];
//        if(num>mx/2)break;
        for(int j=2; num<=1000000; j++)
        {
            num=v[i]*j;
            if(num>mx)break;
            if(cnt[num]==1)
            {
                dp[num]=max(dp[num/j]+1,dp[num]);
                cout<<num<<" "<<dp[num/j]<<" "<<dp[num]<<endl;
            }
        }
        ans=max(ans,dp[v[i]]);
    }
//    for(int i=0;i<v.size();i++)ans=max(ans,dp[v[i]]);
    P(ans),NL;
    return 0;
}
//10
//2 6 9 13 39 42 49 50 65 100


using System;
using System.Collections.Generic;
using System.Linq;
using Solver.Ex;
using Debug = System.Diagnostics.Debug;
using Watch = System.Diagnostics.Stopwatch;
using StringBuilder = System.Text.StringBuilder;
namespace Solver
{
    public class Solver
    {
        public void Solve()
        {
            var n = sc.Integer();
            var m = sc.Integer();
            var cum = new int[30, n + 50];
            var q = new int[m][];
            for (int i = 0; i < m; i++)
                q[i] = sc.Integer(3);
            for (int i = 0; i < m; i++)
            {
                var l = q[i][0];
                var r = q[i][1] + 1;
                var v = q[i][2];
                for (int j = 0; j < 30; j++)
                    if (((v >> j) & 1) == 1)
                    {
                        cum[j, l]++;
                        cum[j, r]--;
                    }

            }
            for (int i = 0; i < n; i++)
                for (int j = 0; j < 30; j++)
                    if (cum[j, i] > 0)
                        cum[j, i] = 1;
            var a = new int[n];
            for (int j = 0; j < 30; j++)
                for (int i = 1; i <= n; i++)
                    cum[j, i] = cum[j, i] + cum[j, i - 1];
            for (int i = 1; i <= n; i++)
                for (int j = 0; j < 30; j++)
                    if (cum[j, i] > 0)
                        a[i - 1] += (1 << j);

            for (int j = 0; j < 30; j++)
                for (int i = 1; i <= n; i++)
                    cum[j, i] += cum[j, i - 1];
            for (int i = 0; i < m; i++)
            {
                var l = q[i][0] - 1;
                var r = q[i][1];
                var v = q[i][2];
                for (int j = 0; j < 30; j++)
                {
                    var t = cum[j, r] - cum[j, l];
                    if (((v >> j) & 1) == 1)
                    {

                        if (t < r - l)
                        {
                            IO.Printer.Out.WriteLine("NO");
                            return;
                        }
                    }
                    else
                    {
                        if (t ==r-l)
                        {
                            IO.Printer.Out.WriteLine("NO");
                            return;
                        }
                    }
                }
            }
            IO.Printer.Out.WriteLine(a.AsJoinedString());

        }

        internal IO.StreamScanner sc;
    }

    #region Main and Settings
    static class Program
    {
        static void Main(string[] arg)
        {
#if DEBUG
            var errStream = new System.IO.FileStream(@"..\..\dbg.out", System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.ReadWrite);
            Debug.Listeners.Add(new System.Diagnostics.TextWriterTraceListener(errStream, "debugStream"));
            Debug.AutoFlush = false;
            var sw = new Watch(); sw.Start();
            try
            {
#endif
                var solver = new Solver();
                solver.sc = new IO.StreamScanner(Console.OpenStandardInput());
                solver.Solve();
                IO.Printer.Out.Flush();
#if DEBUG
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex.Message);
                Console.Error.WriteLine(ex.StackTrace);
            }
            finally
            {
                sw.Stop();
                Console.ForegroundColor = ConsoleColor.Green;
                Console.Error.WriteLine("Time:{0}ms", sw.ElapsedMilliseconds);
                Debug.Close();
                System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);
            }
#endif
        }

    }
    #endregion
}
#region IO Helper
namespace Solver.IO
{
    public class Printer : System.IO.StreamWriter
    {
        static Printer() { Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false }; }
        public static Printer Out { get; set; }
        public override IFormatProvider FormatProvider { get { return System.Globalization.CultureInfo.InvariantCulture; } }
        public Printer(System.IO.Stream stream) : base(stream, new System.Text.UTF8Encoding(false, true)) { }
        public Printer(System.IO.Stream stream, System.Text.Encoding encoding) : base(stream, encoding) { }
        public void Write<T>(string format, IEnumerable<T> source) { Write(format, source.OfType<object>().ToArray()); }
        public void WriteLine<T>(string format, IEnumerable<T> source) { WriteLine(format, source.OfType<object>().ToArray()); }
    }
    public class StreamScanner
    {
        public StreamScanner(System.IO.Stream stream) { iStream = stream; }
        private readonly System.IO.Stream iStream;
        private readonly byte[] buf = new byte[1024];
        private int len, ptr;
        private bool eof = false;
        public bool IsEndOfStream { get { return eof; } }
        const byte lb = 33, ub = 126, el = 10, cr = 13;
        public byte read()
        {
            if (eof) throw new System.IO.EndOfStreamException();
            if (ptr >= len) { ptr = 0; if ((len = iStream.Read(buf, 0, 1024)) <= 0) { eof = true; return 0; } }
            return buf[ptr++];
        }
        public char Char() { byte b = 0; do b = read(); while (b < lb || ub < b);            return (char)b; }
        public char[] Char(int n) { var a = new char[n]; for (int i = 0; i < n; i++) a[i] = Char(); return a; }
        public char[][] Char(int n, int m) { var a = new char[n][]; for (int i = 0; i < n; i++) a[i] = Char(m); return a; }
        public string Scan()
        {
            if (eof) throw new System.IO.EndOfStreamException();
            StringBuilder sb = null;
            var enc = System.Text.UTF8Encoding.Default;
            do
            {
                for (; ptr < len && (buf[ptr] < lb || ub < buf[ptr]); ptr++) ;
                if (ptr < len) break;
                ptr = 0;
                if ((len = iStream.Read(buf, 0, 1024)) <= 0) { eof = true; return ""; }
            } while (true);
            do
            {
                var f = ptr;
                for (; ptr < len; ptr++)
                    if (buf[ptr] < lb || ub < buf[ptr])
                    //if(buf[i]==cr||buf[i]==el)
                    {
                        string s;
                        if (sb == null) s = enc.GetString(buf, f, ptr - f);
                        else { sb.Append(enc.GetChars(buf, f, ptr - f)); s = sb.ToString(); }
                        ptr++; return s;
                    }
                if (sb == null) sb = new StringBuilder(enc.GetString(buf, f, len - f));
                else sb.Append(enc.GetChars(buf, ptr, len - ptr));
                ptr = 0;

            }
            while (!eof && (len = iStream.Read(buf, 0, 1024)) > 0);
            eof = true; return (sb != null) ? sb.ToString() : "";
        }
        public long Long()
        {
            long ret = 0; byte b = 0; bool isMynus = false;
            const byte zr = 48, nn = 57, my = 45;
            do b = read();
            while (b != my && (b < zr || nn < b));
            if (b == my) { isMynus = true; b = read(); }
            for (; true; b = read())
                if (b < zr || nn < b)
                    return isMynus ? -ret : ret;
                else ret = ret * 10 + b - zr;
        }
        public int Integer()
        {
            int ret = 0; byte b = 0; bool isMynus = false;
            const byte zr = 48, nn = 57, my = 45;
            do b = read();
            while (b != my && (b < zr || nn < b));
            if (b == my) { isMynus = true; b = read(); }
            for (; true; b = read())
                if (b < zr || nn < b)
                    return isMynus ? -ret : ret;
                else ret = ret * 10 + b - zr;
        }
        public double Double() { return double.Parse(Scan(), System.Globalization.CultureInfo.InvariantCulture); }
        public string[] Scan(int n) { var a = new string[n]; for (int i = 0; i < n; i++) a[i] = Scan(); return a; }
        public double[] Double(int n) { var a = new double[n]; for (int i = 0; i < n; i++) a[i] = Double(); return a; }
        public int[] Integer(int n) { var a = new int[n]; for (int i = 0; i < n; i++) a[i] = Integer(); return a; }
        public long[] Long(int n) { var a = new long[n]; for (int i = 0; i < n; i++)a[i] = Long(); return a; }
        public void Flush() { iStream.Flush(); }
    }
}
#endregion
#region Extension
namespace Solver.Ex
{
    static public partial class EnumerableEx
    {
        static public string AsString(this IEnumerable<char> ie) { return new string(ie.ToArray()); }
        static public string AsJoinedString<T>(this IEnumerable<T> ie, string st = " ") { return string.Join(st, ie); }
        static public T[] Enumerate<T>(this int n, Func<int, T> f) { var a = new T[n]; for (int i = 0; i < n; i++) a[i] = f(i); return a; }
    }
}
#endregion


using System;
using System.Collections.Generic;
using System.Linq;
using Solver.Ex;
using Debug = System.Diagnostics.Debug;
using Watch = System.Diagnostics.Stopwatch;
using StringBuilder = System.Text.StringBuilder;
namespace Solver
{
    public class Solver
    {
        public void Solve()
        {
            var n = sc.Integer();
            var m = sc.Integer();
            var q = new int[m][];
            for (int i = 0; i < m; i++)
                q[i] = sc.Integer(3);
            var a = new int[n];
            for (int i = 0; i < 30; i++)
            {
                var imos = new int[n + 1];
                for (int j = 0; j < m; j++)
                {
                    var l = q[j][0] - 1;
                    var r = q[j][1];
                    if (((q[j][2] >> i) & 1) == 1)
                    {
                        imos[l]++;
                        imos[r]--;
                    }
                }
                var cum = new int[n + 1];
                for (int j = 1; j <= n; j++)
                    imos[j] += imos[j - 1];
                for (int j = 0; j <= n; j++)
                    if (imos[j] > 0) imos[j] = 1;
                for (int j = 0; j < n; j++)
                    if (imos[j] > 0) a[j] |= 1 << i;
                for (int j = 1; j <= n; j++)
                    cum[j] = cum[j - 1] + imos[j-1];
                for (int j = 0; j < m; j++)
                {
                    var l = q[j][0] - 1;
                    var r = q[j][1];
                    var v=q[j][2];
                    var t = cum[r] - cum[l];
                    if (((v >> i) & 1) == 0 && t == r - l)
                    {
                        IO.Printer.Out.WriteLine("NO");
                        return;
                    }

                }
            }
            IO.Printer.Out.WriteLine("YES");
            IO.Printer.Out.WriteLine(a.AsJoinedString());

        }

        internal IO.StreamScanner sc;
    }

    #region Main and Settings
    static class Program
    {
        static void Main(string[] arg)
        {
#if DEBUG
            var errStream = new System.IO.FileStream(@"..\..\dbg.out", System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.ReadWrite);
            Debug.Listeners.Add(new System.Diagnostics.TextWriterTraceListener(errStream, "debugStream"));
            Debug.AutoFlush = false;
            var sw = new Watch(); sw.Start();
            try
            {
#endif
                var solver = new Solver();
                solver.sc = new IO.StreamScanner(Console.OpenStandardInput());
                solver.Solve();
                IO.Printer.Out.Flush();
#if DEBUG
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex.Message);
                Console.Error.WriteLine(ex.StackTrace);
            }
            finally
            {
                sw.Stop();
                Console.ForegroundColor = ConsoleColor.Green;
                Console.Error.WriteLine("Time:{0}ms", sw.ElapsedMilliseconds);
                Debug.Close();
                System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);
            }
#endif
        }

    }
    #endregion
}
#region IO Helper
namespace Solver.IO
{
    public class Printer : System.IO.StreamWriter
    {
        static Printer() { Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false }; }
        public static Printer Out { get; set; }
        public override IFormatProvider FormatProvider { get { return System.Globalization.CultureInfo.InvariantCulture; } }
        public Printer(System.IO.Stream stream) : base(stream, new System.Text.UTF8Encoding(false, true)) { }
        public Printer(System.IO.Stream stream, System.Text.Encoding encoding) : base(stream, encoding) { }
        public void Write<T>(string format, IEnumerable<T> source) { Write(format, source.OfType<object>().ToArray()); }
        public void WriteLine<T>(string format, IEnumerable<T> source) { WriteLine(format, source.OfType<object>().ToArray()); }
    }
    public class StreamScanner
    {
        public StreamScanner(System.IO.Stream stream) { iStream = stream; }
        private readonly System.IO.Stream iStream;
        private readonly byte[] buf = new byte[1024];
        private int len, ptr;
        private bool eof = false;
        public bool IsEndOfStream { get { return eof; } }
        const byte lb = 33, ub = 126, el = 10, cr = 13;
        public byte read()
        {
            if (eof) throw new System.IO.EndOfStreamException();
            if (ptr >= len) { ptr = 0; if ((len = iStream.Read(buf, 0, 1024)) <= 0) { eof = true; return 0; } }
            return buf[ptr++];
        }
        public char Char() { byte b = 0; do b = read(); while (b < lb || ub < b);            return (char)b; }
        public char[] Char(int n) { var a = new char[n]; for (int i = 0; i < n; i++) a[i] = Char(); return a; }
        public char[][] Char(int n, int m) { var a = new char[n][]; for (int i = 0; i < n; i++) a[i] = Char(m); return a; }
        public string Scan()
        {
            if (eof) throw new System.IO.EndOfStreamException();
            StringBuilder sb = null;
            var enc = System.Text.UTF8Encoding.Default;
            do
            {
                for (; ptr < len && (buf[ptr] < lb || ub < buf[ptr]); ptr++) ;
                if (ptr < len) break;
                ptr = 0;
                if ((len = iStream.Read(buf, 0, 1024)) <= 0) { eof = true; return ""; }
            } while (true);
            do
            {
                var f = ptr;
                for (; ptr < len; ptr++)
                    if (buf[ptr] < lb || ub < buf[ptr])
                    //if(buf[i]==cr||buf[i]==el)
                    {
                        string s;
                        if (sb == null) s = enc.GetString(buf, f, ptr - f);
                        else { sb.Append(enc.GetChars(buf, f, ptr - f)); s = sb.ToString(); }
                        ptr++; return s;
                    }
                if (sb == null) sb = new StringBuilder(enc.GetString(buf, f, len - f));
                else sb.Append(enc.GetChars(buf, ptr, len - ptr));
                ptr = 0;

            }
            while (!eof && (len = iStream.Read(buf, 0, 1024)) > 0);
            eof = true; return (sb != null) ? sb.ToString() : "";
        }
        public long Long()
        {
            long ret = 0; byte b = 0; bool isMynus = false;
            const byte zr = 48, nn = 57, my = 45;
            do b = read();
            while (b != my && (b < zr || nn < b));
            if (b == my) { isMynus = true; b = read(); }
            for (; true; b = read())
                if (b < zr || nn < b)
                    return isMynus ? -ret : ret;
                else ret = ret * 10 + b - zr;
        }
        public int Integer()
        {
            int ret = 0; byte b = 0; bool isMynus = false;
            const byte zr = 48, nn = 57, my = 45;
            do b = read();
            while (b != my && (b < zr || nn < b));
            if (b == my) { isMynus = true; b = read(); }
            for (; true; b = read())
                if (b < zr || nn < b)
                    return isMynus ? -ret : ret;
                else ret = ret * 10 + b - zr;
        }
        public double Double() { return double.Parse(Scan(), System.Globalization.CultureInfo.InvariantCulture); }
        public string[] Scan(int n) { var a = new string[n]; for (int i = 0; i < n; i++) a[i] = Scan(); return a; }
        public double[] Double(int n) { var a = new double[n]; for (int i = 0; i < n; i++) a[i] = Double(); return a; }
        public int[] Integer(int n) { var a = new int[n]; for (int i = 0; i < n; i++) a[i] = Integer(); return a; }
        public long[] Long(int n) { var a = new long[n]; for (int i = 0; i < n; i++)a[i] = Long(); return a; }
        public void Flush() { iStream.Flush(); }
    }
}
#endregion
#region Extension
namespace Solver.Ex
{
    static public partial class EnumerableEx
    {
        static public string AsString(this IEnumerable<char> ie) { return new string(ie.ToArray()); }
        static public string AsJoinedString<T>(this IEnumerable<T> ie, string st = " ") { return string.Join(st, ie); }
        static public T[] Enumerate<T>(this int n, Func<int, T> f) { var a = new T[n]; for (int i = 0; i < n; i++) a[i] = f(i); return a; }
    }
}
#endregion


using System;
using System.Collections.Generic;
using System.Linq;
using Solver.Ex;
using Debug = System.Diagnostics.Debug;
using Watch = System.Diagnostics.Stopwatch;
using StringBuilder = System.Text.StringBuilder;
namespace Solver
{
    public class Solver
    {
        public void Solve()
        {
            var n = sc.Integer();
            var m = sc.Integer();
            var cum = new int[30, n + 50];
            var q = new int[m][];
            for (int i = 0; i < m; i++)
                q[i] = sc.Integer(3);
            for (int i = 0; i < m; i++)
            {
                var l = q[i][0];
                var r = q[i][1] + 1;
                var v = q[i][2];
                for (int j = 0; j < 30; j++)
                    if (((v >> j) & 1) == 1)
                    {
                        cum[j, l]++;
                        cum[j, r]--;
                    }

            }
            for (int j = 0; j < 30; j++)
                for (int i = 1; i <= n; i++)
                    cum[j, i] = cum[j, i] + cum[j, i - 1];
            for (int i = 0; i < n; i++)
                for (int j = 0; j < 30; j++)
                    if (cum[j, i] > 0)
                        cum[j, i] = 1;
            var a = new int[n];
            for (int i = 1; i <= n; i++)
                for (int j = 0; j < 30; j++)
                    if (cum[j, i] > 0)
                        a[i - 1] += (1 << j);

            for (int j = 0; j < 30; j++)
                for (int i = 1; i <= n; i++)
                    cum[j, i] += cum[j, i - 1];
            for (int i = 0; i < m; i++)
            {
                var l = q[i][0] - 1;
                var r = q[i][1];
                var v = q[i][2];
                for (int j = 0; j < 30; j++)
                {
                    var t = cum[j, r] - cum[j, l];
                    if (((v >> j) & 1) == 1)
                    {

                        if (t != r - l)
                        {
                            IO.Printer.Out.WriteLine("NO");
                            return;
                        }
                    }
                    else
                    {
                        if (t == r - l)
                        {
                            IO.Printer.Out.WriteLine("NO");
                            return;
                        }
                    }
                }
            }
            IO.Printer.Out.WriteLine("YES");
            IO.Printer.Out.WriteLine(a.AsJoinedString());

        }

        internal IO.StreamScanner sc;
    }

    #region Main and Settings
    static class Program
    {
        static void Main(string[] arg)
        {
#if DEBUG
            var errStream = new System.IO.FileStream(@"..\..\dbg.out", System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.ReadWrite);
            Debug.Listeners.Add(new System.Diagnostics.TextWriterTraceListener(errStream, "debugStream"));
            Debug.AutoFlush = false;
            var sw = new Watch(); sw.Start();
            try
            {
#endif
                var solver = new Solver();
                solver.sc = new IO.StreamScanner(Console.OpenStandardInput());
                solver.Solve();
                IO.Printer.Out.Flush();
#if DEBUG
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex.Message);
                Console.Error.WriteLine(ex.StackTrace);
            }
            finally
            {
                sw.Stop();
                Console.ForegroundColor = ConsoleColor.Green;
                Console.Error.WriteLine("Time:{0}ms", sw.ElapsedMilliseconds);
                Debug.Close();
                System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);
            }
#endif
        }

    }
    #endregion
}
#region IO Helper
namespace Solver.IO
{
    public class Printer : System.IO.StreamWriter
    {
        static Printer() { Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false }; }
        public static Printer Out { get; set; }
        public override IFormatProvider FormatProvider { get { return System.Globalization.CultureInfo.InvariantCulture; } }
        public Printer(System.IO.Stream stream) : base(stream, new System.Text.UTF8Encoding(false, true)) { }
        public Printer(System.IO.Stream stream, System.Text.Encoding encoding) : base(stream, encoding) { }
        public void Write<T>(string format, IEnumerable<T> source) { Write(format, source.OfType<object>().ToArray()); }
        public void WriteLine<T>(string format, IEnumerable<T> source) { WriteLine(format, source.OfType<object>().ToArray()); }
    }
    public class StreamScanner
    {
        public StreamScanner(System.IO.Stream stream) { iStream = stream; }
        private readonly System.IO.Stream iStream;
        private readonly byte[] buf = new byte[1024];
        private int len, ptr;
        private bool eof = false;
        public bool IsEndOfStream { get { return eof; } }
        const byte lb = 33, ub = 126, el = 10, cr = 13;
        public byte read()
        {
            if (eof) throw new System.IO.EndOfStreamException();
            if (ptr >= len) { ptr = 0; if ((len = iStream.Read(buf, 0, 1024)) <= 0) { eof = true; return 0; } }
            return buf[ptr++];
        }
        public char Char() { byte b = 0; do b = read(); while (b < lb || ub < b);            return (char)b; }
        public char[] Char(int n) { var a = new char[n]; for (int i = 0; i < n; i++) a[i] = Char(); return a; }
        public char[][] Char(int n, int m) { var a = new char[n][]; for (int i = 0; i < n; i++) a[i] = Char(m); return a; }
        public string Scan()
        {
            if (eof) throw new System.IO.EndOfStreamException();
            StringBuilder sb = null;
            var enc = System.Text.UTF8Encoding.Default;
            do
            {
                for (; ptr < len && (buf[ptr] < lb || ub < buf[ptr]); ptr++) ;
                if (ptr < len) break;
                ptr = 0;
                if ((len = iStream.Read(buf, 0, 1024)) <= 0) { eof = true; return ""; }
            } while (true);
            do
            {
                var f = ptr;
                for (; ptr < len; ptr++)
                    if (buf[ptr] < lb || ub < buf[ptr])
                    //if(buf[i]==cr||buf[i]==el)
                    {
                        string s;
                        if (sb == null) s = enc.GetString(buf, f, ptr - f);
                        else { sb.Append(enc.GetChars(buf, f, ptr - f)); s = sb.ToString(); }
                        ptr++; return s;
                    }
                if (sb == null) sb = new StringBuilder(enc.GetString(buf, f, len - f));
                else sb.Append(enc.GetChars(buf, ptr, len - ptr));
                ptr = 0;

            }
            while (!eof && (len = iStream.Read(buf, 0, 1024)) > 0);
            eof = true; return (sb != null) ? sb.ToString() : "";
        }
        public long Long()
        {
            long ret = 0; byte b = 0; bool isMynus = false;
            const byte zr = 48, nn = 57, my = 45;
            do b = read();
            while (b != my && (b < zr || nn < b));
            if (b == my) { isMynus = true; b = read(); }
            for (; true; b = read())
                if (b < zr || nn < b)
                    return isMynus ? -ret : ret;
                else ret = ret * 10 + b - zr;
        }
        public int Integer()
        {
            int ret = 0; byte b = 0; bool isMynus = false;
            const byte zr = 48, nn = 57, my = 45;
            do b = read();
            while (b != my && (b < zr || nn < b));
            if (b == my) { isMynus = true; b = read(); }
            for (; true; b = read())
                if (b < zr || nn < b)
                    return isMynus ? -ret : ret;
                else ret = ret * 10 + b - zr;
        }
        public double Double() { return double.Parse(Scan(), System.Globalization.CultureInfo.InvariantCulture); }
        public string[] Scan(int n) { var a = new string[n]; for (int i = 0; i < n; i++) a[i] = Scan(); return a; }
        public double[] Double(int n) { var a = new double[n]; for (int i = 0; i < n; i++) a[i] = Double(); return a; }
        public int[] Integer(int n) { var a = new int[n]; for (int i = 0; i < n; i++) a[i] = Integer(); return a; }
        public long[] Long(int n) { var a = new long[n]; for (int i = 0; i < n; i++)a[i] = Long(); return a; }
        public void Flush() { iStream.Flush(); }
    }
}
#endregion
#region Extension
namespace Solver.Ex
{
    static public partial class EnumerableEx
    {
        static public string AsString(this IEnumerable<char> ie) { return new string(ie.ToArray()); }
        static public string AsJoinedString<T>(this IEnumerable<T> ie, string st = " ") { return string.Join(st, ie); }
        static public T[] Enumerate<T>(this int n, Func<int, T> f) { var a = new T[n]; for (int i = 0; i < n; i++) a[i] = f(i); return a; }
    }
}
#endregion