import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DGoodSequences solver = new DGoodSequences();
        solver.solve(1, in, out);
        out.close();
    }

    static class DGoodSequences {
        int MAXN = 100005;
        PrintWriter out;
        InputReader in;
        int[] spf = new int[MAXN];
        ArrayList<Integer>[] all_possible = new ArrayList[MAXN];
        int[] smallest = new int[MAXN];

        void pre() {
            spf[1] = 1;
            for (int i = 2; i < MAXN; i++)
                spf[i] = i;
            for (int i = 4; i < MAXN; i += 2)
                spf[i] = 2;
            for (int i = 3; i * i < MAXN; i++) {
                if (spf[i] == i) {
                    for (int j = i * i; j < MAXN; j += i) {
                        if (spf[j] == j)
                            spf[j] = i;
                    }
                }
            }
        }

        void hola() {
            int i = 0, j = 0, k = 0;
            for (i = 0; i < MAXN; i++)
                all_possible[i] = new ArrayList<>();
            for (i = 2; i < MAXN; i++) {
                ArrayList<Integer> prime_factors = new ArrayList<>();
                int x = i;
                int curr = spf[i];
                prime_factors.add(curr);
                while (x > 1) {
                    x /= curr;
                    if (curr == spf[x])
                        continue;
                    prime_factors.add(spf[x]);
                    curr = spf[x];
                }
                int sz = prime_factors.size();
                for (j = 1; j < (1 << sz); j++) {
                    int prod = 1;
                    for (k = 0; k < sz; k++) {
                        if ((j & (1 << k)) > 0)
                            prod *= prime_factors.get(k);
                    }
                    all_possible[i].add(prod);
                    smallest[i] = prod;
                }
            }
        }

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            this.out = out;
            this.in = in;
            int n = ni();
            pre();
            hola();
            int[] arr = new int[n];
            int i = 0;
            for (i = 0; i < n; i++)
                arr[i] = ni();
            int[] dp = new int[MAXN];
            for (i = 0; i < n; i++) {
                if (arr[i] == 1)
                    continue;
                for (int x : all_possible[arr[i]]) {
                    if (x == arr[i])
                        continue;
                    dp[smallest[arr[i]]] = Math.max(dp[smallest[arr[i]]], dp[x] + 1);
                }
            }
            int ans = 1;
            for (i = 0; i < MAXN; i++)
                ans = Math.max(dp[i], ans);
            pn(ans);
        }

        int ni() {
            return in.nextInt();
        }

        void pn(long zx) {
            out.println(zx);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new UnknownError();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new UnknownError();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public String next() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuffer res = new StringBuffer();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));

            return res.toString();
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}


#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mod 1000000007
using namespace std;
ld const EPS = 1e-6;
int const N = 1e5+9;
int dp[N];
int main(){
    int n;
    cin>>n;
    int arr[n];
    for(int i = 0;i<n;i++){
        cin>>arr[i];
        dp[arr[i]]=1;
    }
    for(int i = 0;i<n;i++){
        for(int j = 2;j*j<=arr[i];j++){
            if(arr[i]%j == 0){
                dp[arr[i]] = max(dp[arr[i]],dp[j]+1);
                dp[arr[i]] = max(dp[arr[i]],dp[arr[i]/j]+1);
            }
        }
        for(int j = 2;j*j<=arr[i];j++){
            if(arr[i]%j == 0){
                dp[arr[i]/j] = dp[arr[i]];
                dp[j] = dp[arr[i]];

            }
        }

    }
    cout<<*max_element(dp,dp+N);
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mod 1000000007
using namespace std;
ld const EPS = 1e-6;
int const N = 1e5+9;
int dp[N];
int main(){
    int n;
    cin>>n;
    int arr[n];
    for(int i = 0;i<n;i++){
        cin>>arr[i];
    }
    for(int i = 0;i<n;i++){
        dp[arr[i]]=1;
        for(int j = 2;j*j<=arr[i];j++){
            if(arr[i]%j == 0){
                dp[arr[i]] = max(dp[arr[i]],dp[j]+1);
                dp[arr[i]] = max(dp[arr[i]],dp[arr[i]/j]+1);
            }
        }
        for(int j = 2;j*j<=arr[i];j++){
            if(arr[i]%j == 0){
                if(dp[arr[i]/j])
                    dp[arr[i]/j] = dp[arr[i]];
                if(dp[j])
                    dp[j] = dp[arr[i]];

            }
        }

    }
    cout<<*max_element(dp,dp+N);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
using namespace std;
int n, a[100001], l[100001], check[100001];
vector<int> prime, tmp;
int main()
{
    //freopen("1.in", "r", stdin);
    //freopen("1.out", "w", stdout);
    for(int i = 2; i <= 100000; ++i){
        if(!check[i]) prime.push_back(i);
        int len = prime.size();
        for(int j = 0; j < len; ++j){
            if(i * prime[j] > 100000) break;
            check[i * prime[j]] = 1;
            if(i % prime[j] == 0) break;
        }
    }
    scanf("%d", &n);
    for(int i = 0; i < n; ++i) scanf("%d", &a[i]);
    int len = prime.size();
    l[1] = 1;
    for(int i = 0; i < n; ++i){
        int max = 0, Len = 0;
        for(int j = 0; j < len; ++j){
            if(prime[j] > a[i]) break;
            if(a[i] % prime[j] == 0){
                tmp.push_back(prime[j]);
                if(l[tmp[Len]] > max) max = l[tmp[Len]];
                ++Len;
            }
        }
        for(int j = 0; j < Len; ++j) l[tmp[j]] = max + 1;
        tmp.clear();
    }
    int ans = 0;
    for(int i = 0; i <= a[n - 1]; ++i)
        if(l[i] > ans) ans = l[i];
    printf("%d", ans);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
using namespace std;
int n, a[100001], l[100001], check[100001];
vector<int> prime, tmp;
int main()
{
    //freopen("1.in", "r", stdin);
    //freopen("1.out", "w", stdout);
    for(int i = 2; i <= 100000; ++i){
        if(!check[i]) prime.push_back(i);
        int len = prime.size();
        for(int j = 0; j < len; ++j){
            if(i * prime[j] > 100000) break;
            check[i * prime[j]] = 1;
            if(i % prime[j] == 0) break;
        }
    }
    scanf("%d", &n);
    for(int i = 0; i < n; ++i) scanf("%d", &a[i]);
    int len = prime.size();
    l[1] = 1;
    for(int i = 0; i < n; ++i){
        int max = 0, Len = 0, x = a[i];
        for(int j = 0; j < len; ++j){
            if(prime[j] > x) break;
            if(x % prime[j] == 0){
                tmp.push_back(prime[j]);
                if(l[tmp[Len]] > max) max = l[tmp[Len]];
                ++Len;
                while(x % prime[j] == 0) x /= prime[j];
            }
        }
        for(int j = 0; j < Len; ++j) l[tmp[j]] = max + 1;
        tmp.clear();
    }
    int ans = 0;
    for(int i = 0; i <= a[n - 1]; ++i)
        if(l[i] > ans) ans = l[i];
    printf("%d", ans);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
int n, a[100001], l[100001], check[100001];
vector<int> prime, tmp;
int main()
{
    //freopen("1.in", "r", stdin);
    //freopen("1.out", "w", stdout);
    for(int i = 2; i <= 100000; ++i){
        if(!check[i]) prime.push_back(i);
        int len = prime.size();
        for(int j = 0; j < len; ++j){
            if(i * prime[j] > 100000) break;
            check[i * prime[j]] = 1;
            if(i % prime[j] == 0) break;
        }
    }
    scanf("%d", &n);
    for(int i = 0; i < n; ++i) scanf("%d", &a[i]);
    int len = prime.size();
    l[1] = 1;
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < len; ++j){
            if(prime[j] > a[i]) break;
            if(a[i] % prime[j] == 0) tmp.push_back(prime[j]);
        }
        int Len = tmp.size(), max = 0;
        for(int j = 0; j < Len; ++j)
            if(l[tmp[j]] > max) max = l[tmp[j]];
        for(int j = 0; j < Len; ++j) l[tmp[j]] = max + 1;
        tmp.clear();
    }
    int ans = 0;
    for(int i = 0; i <= a[n - 1]; ++i)
        if(l[i] > ans) ans = l[i];
    printf("%d", ans);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
using namespace std;
int n, a[100001], l[100001], check[100001];
vector<int> prime, tmp;
int main()
{
    //freopen("1.in", "r", stdin);
    //freopen("1.out", "w", stdout);
    for(int i = 2; i <= 100000; ++i){
        if(!check[i]) prime.push_back(i);
        int len = prime.size();
        for(int j = 0; j < len; ++j){
            if(i * prime[j] > 100000) break;
            check[i * prime[j]] = 1;
            if(i % prime[j] == 0) break;
        }
    }
    scanf("%d", &n);
    for(int i = 0; i < n; ++i) scanf("%d", &a[i]);
    int len = prime.size();
    l[1] = 1;
    for(int i = 0; i < n; ++i){
        int x = sqrt(a[i]);
        for(int j = 0; j < len; ++j){
            if(prime[j] > x) break;
            if(a[i] % prime[j] == 0) tmp.push_back(prime[j]);
        }
        int Len = tmp.size(), max = 0;
        for(int j = 0; j < Len; ++j)
            if(l[tmp[j]] > max) max = l[tmp[j]];
        for(int j = 0; j < Len; ++j) l[tmp[j]] = max + 1;
        tmp.clear();
    }
    int ans = 0;
    for(int i = 0; i <= a[n - 1]; ++i)
        if(l[i] > ans) ans = l[i];
    printf("%d", ans);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
int n, a[100001], l[100001], check[100001];
vector<int> prime;
int main()
{
    //freopen("1.in", "r", stdin);
    //freopen("1.out", "w", stdout);
    for(int i = 2; i <= 100000; ++i){
        if(!check[i]) prime.push_back(i);
        int len = prime.size();
        for(int j = 0; j < len; ++j){
            if(i * prime[j] > 100000) break;
            check[i * prime[j]] = 1;
            if(i % prime[j] == 0) break;
        }
    }
    scanf("%d", &n);
    for(int i = 0; i < n; ++i) scanf("%d", &a[i]);
    int len = prime.size();
    l[1] = 1;
    for(int i = 0; i < n; ++i){
        vector<int> tmp;
        for(int j = 0; j < len; ++j){
            if(prime[j] > a[i]) break;
            if(a[i] % prime[j] == 0) tmp.push_back(prime[j]);
        }
        int Len = tmp.size(), max = 0;
        for(int j = 0; j < Len; ++j)
            if(l[tmp[j]] > max) max = l[tmp[j]];
        for(int j = 0; j < Len; ++j) l[tmp[j]] = max + 1;
    }
    int ans = 0;
    for(int i = 0; i < n; ++i)
        if(l[a[i]] > ans) ans = l[a[i]];
    printf("%d", ans);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
int n, a[100001], l[100001], check[100001];
vector<int> prime;
int main()
{
    //freopen("1.in", "r", stdin);
    //freopen("1.out", "w", stdout);
    for(int i = 2; i <= 100000; ++i){
        if(!check[i]) prime.push_back(i);
        int len = prime.size();
        for(int j = 0; j < len; ++j){
            if(i * prime[j] > 100000) break;
            check[i * prime[j]] = 1;
            if(i % prime[j] == 0) break;
        }
    }
    scanf("%d", &n);
    for(int i = 0; i < n; ++i) scanf("%d", &a[i]);
    int len = prime.size();
    l[1] = 1;
    for(int i = 0; i < n; ++i){
        vector<int> tmp;
        for(int j = 0; j < len; ++j){
            if(prime[j] > a[i]) break;
            if(a[i] % prime[j] == 0) tmp.push_back(prime[j]);
        }
        int Len = tmp.size(), max = 0;
        for(int j = 0; j < Len; ++j)
            if(l[tmp[j]] > max) max = l[tmp[j]];
        for(int j = 0; j < Len; ++j) l[tmp[j]] = max + 1;
    }
    int ans = 0;
    for(int i = 0; i <= a[n - 1]; ++i)
        if(l[i] > ans) ans = l[i];
    printf("%d", ans);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
int n, a[100001], l[100001], check[100001];
vector<int> prime;
int main()
{
    //freopen("1.in", "r", stdin);
    //freopen("1.out", "w", stdout);
    for(int i = 2; i <= 100000; ++i){
        if(!check[i]) prime.push_back(i);
        int len = prime.size();
        for(int j = 0; j < len; ++j){
            if(i * prime[j] > 100000) break;
            check[i * prime[j]] = 1;
            if(i % prime[j] == 0) break;
        }
    }
    scanf("%d", &n);
    for(int i = 0; i < n; ++i) scanf("%d", &a[i]);
    int len = prime.size();
    for(int i = 0; i < n; ++i){
        vector<int> tmp;
        for(int j = 0; j < len; ++j){
            if(prime[j] > a[i]) break;
            if(a[i] % prime[j] == 0) tmp.push_back(prime[j]);
        }
        int Len = tmp.size(), max = 0;
        for(int j = 0; j < Len; ++j)
            if(l[tmp[j]] > max) max = l[tmp[j]];
        for(int j = 0; j < Len; ++j) l[tmp[j]] = max + 1;
    }
    int ans = 0;
    for(int i = 0; i < n; ++i)
        if(l[a[i]] > ans) ans = l[a[i]];
    printf("%d", ans);
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

int maxn=100005;

const int N=100005;

vector<int>length(maxn);

vector<int>Primes((N+1),1);

void sieve()
 {
         Primes[0]=0;
         Primes[1]=0;

					for(int i=2;i<=sqrt(N);i++)
					{
							if(Primes[i]==1)
							{
							 	for(int j=i;i*j<=N;j++)
							 	{
									 Primes[i*j]=0;
								}
							 }
					}
 }

int main()
{
    int n;
    cin>>n;
    vector<int>a(n);
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    if(n==1)
    {
        cout<<"1"<<endl;
        return 0;
    }

    for(int i=0;i<n;i++)
    {
         vector<int>v;
        if(Primes[a[i]])
            v.push_back(a[i]);
        for(int j=2;j*j<=a[i];j++)
        {
            if(a[i]%j==0)
            {
                if(Primes[j])
                    v.push_back(j);
                if(Primes[a[i]/j]&&j*j!=a[i])
                    v.push_back(a[i]/j);
            }
        }
        int len=0;
        for(int i=0;i<v.size();i++)
        {
            len=max(len,length[v[i]]);
        }
        for (int i=0;i<v.size();i++)
        {
            length[v[i]]=len+1;
        }
    }
    cout<<*max_element(length.begin(),length.end());
}


#include <iostream>
#include<vector>
#include<algorithm>

using namespace std;

#define maxn 100001

vector<int>Primes(maxn);

vector<int>v(maxn,1);

void least_prime_factor()
 {

    Primes[1]=1;
					for(int i=2;i<=maxn;i++)
					{
						Primes[i]=i;
					}
					for(int i=4;i<=maxn;i+=2)
					{
						Primes[i]=2;
					}
					for(int i=3;i*i<=maxn;i++)
					{
						if(Primes[i]==i)
						{
							for(int j=i*i;j<=maxn;j+=2*i)
							{
								if(Primes[j]==j)
								   Primes[j]=i;
							}
						}
					}

 }

 void func(vector<int>input)
 {
     for(int i=0;i<input.size();i++)
     {
         if(input[i]==1||Primes[input[i]]==input[i])
            continue;
         int x=input[i];
         while(x!=1)
         {
             v[Primes[x]]+=1;
             int temp=x;
             while(Primes[temp]==Primes[x]){
             x/=Primes[x];
             }
         }
     }
 }

 int main()
 {
     least_prime_factor();
     int n;
     cin>>n;
     vector<int>input(n);
     for(int i=0;i<n;i++)
     {
         cin>>input[i];
     }
     func(input);
     cout<<*max_element(v.begin(),v.end())<<endl;
 }


#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli n;
    cin>>n;
    lli i,j,a[n],seq[100005]={0},v[100005]={0},ans=0,temp,cur,d;
    seq[1]=1;
    for(i=0;i<n;i++) cin>>a[i];
    for(i=2;i<100005;i++)
    {
        if(v[i]==0)
        {
            for(j=i;j<100005;j+=i)
            {
                v[j]=i;
            }
        }
    }

    for(i=0;i<n;i++)
    {
        temp=a[i];
        cur=0;
        while(temp!=1)
        {
            d=v[temp];
            cur=max(cur,seq[d]+1);
            temp/=d;
        }
        ans=max(ans,cur);
        temp=a[i];
        while(temp!=1)
        {
            d=v[temp];
            seq[d]=cur;
            temp/=d;
        }
    }
    cout<<ans;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli n;
    cin>>n;
    lli i,j,a[n],seq[100005]={0},v[100005]={0},ans=1,temp,cur,d;
    seq[1]=1;
    for(i=0;i<n;i++) cin>>a[i];
    for(i=2;i<100005;i++)
    {
        if(v[i]==0)
        {
            for(j=i;j<100005;j+=i)
            {
                v[j]=i;
            }
        }
    }

    for(i=0;i<n;i++)
    {
        temp=a[i];
        cur=0;
        while(temp!=1)
        {
            d=v[temp];
            cur=max(cur,seq[d]+1);
            temp/=d;
        }
        ans=max(ans,cur);
        temp=a[i];
        while(temp!=1)
        {
            d=v[temp];
            seq[d]=cur;
            temp/=d;
        }
    }
    cout<<ans;
    return 0;
}


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

#define endl '\n'
#define int long long

const int N = 1e5+9;
vector<int> d[N];
int dp[N];

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	for(int i = 2; i <= N; i ++)
		for(int j = i; j <= N; j += i)
			d[j].push_back(i);
	int n; cin >> n;
	int ans(0);
	for(int i = 0; i < n; i ++) {
		int a; cin >> a;
		int maxx(0);
		for(int j : d[a])
			maxx = max(maxx, dp[j]);
		for(int j : d[a])
			dp[j] = maxx + 1;
		ans = max(ans, maxx + 1);
	}
	cout << ans << endl;

	return 0;
}


      #include<bits/stdc++.h>
        #include <bitset>
        using namespace std;
        #define ll long long
        #define ld long double
        #define MOD 1000000007
        #define mod9 1000000009
        #define mod 1000003
        #define fast ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
        #define mp make_pair
        #define pb push_back
        #define ct ll t;cin>>t;while(t--)
        #define bi begin()
        #define ei end()
        #define fi first
        #define se second
        #define foe(a,b) for(ll i=a;i<b;i++)
		#define sz(s) s.size()
        bool isPrime(ll n)
        {
            // Corner case
            if (n <= 1)
                return false;

            // Check from 2 to n-1
            for (ll i = 2; i*i <= n; i++)
                if (n % i == 0)
                    return false;

            return true;
        }
        long long binpow(long long a, long long b) {
            long long res = 1;
            while (b > 0) {
                if (b & 1)
                    res = (res%mod) * (a%mod);
                a = (a%mod) * (a%mod);
                b >>= 1;
            }
            return res%mod;
        }

        bool compare(const pair<ll,ll>&a,const pair<ll,ll>&b)
        {
            return (a.se<b.se);
        }
        ll lcm(ll a,ll b)
        {
            return(a*b)/__gcd(a,b);
        }
        // vector<ll>s;
        // set<ll>t;
        void SieveOfEratosthenes()
        {
            ll n=100005;
            bool prime[100005]={false};
            // s[0]=0;
            // s[1]=1;
            // s.pb(1);
            // t.insert(1);
            for (int p=2; p<=n; p++)
            {

               if(prime[p]==false)
               {
                   for(ll j=p+p;j<=100005;j+=p)
                   {
                       prime[j]=true;
                   }
               }
            }
            for(ll i=2;i<100005;i++)
            {
                if(!prime[i])
                {
                    // s.pb(i);
                    // t.insert(i);
                }
            }
        }
        void eea(ll a, ll b, ll & x, ll & y) {
        if (a == 0) {
            x = 0;
            y = 1;
            return ;
        }
        ll x1, y1;
        eea(b % a, a, x1, y1);
        x = y1 - (b / a) * x1;
        y = x1;
        return ;
    }
    ll modinverse(ll a,ll m)
    {
        ll x, y;
        eea(a, m, x, y);
        if (__gcd(a,m) != 1) {
        return -1;
        }
    else {
        x = (x % m + m) % m;
        cout << x << endl;
        return x;
    }
    }
//         ll fact[1000007]={0};
//         ll expo(ll x, ll y) {ll res=1;x=x%MOD;while(y>0){if(y&1)res=(1ll*res*x)%MOD;
//         y=y>>1;x=(1ll*x*x)%MOD;} return res;}
//         void facto() {fact[0]=1;fact[1]=1;for(ll i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%MOD;}
//         ll npr(ll n,ll r) {facto(); ll res=1; res=fact[n]; res=(res*(expo(fact[n-r],MOD-2)))%MOD; return res; }
//         ll ncr(ll n,ll r){ ll res=1; if(r>n-r)r=n-r; for(ll i=0;i<r;i++) {  res*=n-i;  res/=i+1; } return res;}
//             ll C(ll n, ll k) {
//     ll res = 1;
//     for (ll i = 1; i <= k; ++i)
//         res = ((res) * (n - k + i) / i)%MOD;
//     return (ll)(res + 0.01)%MOD;
// }
const int N=1e5+5;
  vector<int>v[N];
  int dp[N];
        int main()
        {
            fast
            // SieveOfEratosthenes();
        //    ct
			 {

                 for(ll i=2;i<=100005;i++)
                 {
                     for(ll j=i;j<=100005;j+=i)
                     {
                         v[j].pb(i);
                     }
                 }
                 ll n;
                 cin>>n;
                 int a[n];
                 foe(0,n)
                 {
                     cin>>a[i];
                 }
                memset(dp,0,sizeof(dp));
                int ans=0;
                 foe(0,n)
                 {
                     int m=0;
                     for(auto j:v[a[i]])
                     {
                         m=max(m,dp[j]);
                     }
                     for(auto j:v[a[i]])
                     {
                         dp[j]=m+1;
                     }
                     ans=max(ans,m+1);
                 }
                 cout<<ans<<"\n";
             }
        }


      #include<bits/stdc++.h>
        #include <bitset>
        using namespace std;
        #define ll long long
        #define ld long double
        #define MOD 1000000007
        #define mod9 1000000009
        #define mod 1000003
        #define fast ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
        #define mp make_pair
        #define pb push_back
        #define ct ll t;cin>>t;while(t--)
        #define bi begin()
        #define ei end()
        #define fi first
        #define se second
        #define foe(a,b) for(ll i=a;i<b;i++)
		#define sz(s) s.size()
        bool isPrime(ll n)
        {
            // Corner case
            if (n <= 1)
                return false;

            // Check from 2 to n-1
            for (ll i = 2; i*i <= n; i++)
                if (n % i == 0)
                    return false;

            return true;
        }
        long long binpow(long long a, long long b) {
            long long res = 1;
            while (b > 0) {
                if (b & 1)
                    res = (res%mod) * (a%mod);
                a = (a%mod) * (a%mod);
                b >>= 1;
            }
            return res%mod;
        }

        bool compare(const pair<ll,ll>&a,const pair<ll,ll>&b)
        {
            return (a.se<b.se);
        }
        ll lcm(ll a,ll b)
        {
            return(a*b)/__gcd(a,b);
        }
        // vector<ll>s;
        // set<ll>t;
        void SieveOfEratosthenes()
        {
            ll n=100005;
            bool prime[100005]={false};
            // s[0]=0;
            // s[1]=1;
            // s.pb(1);
            // t.insert(1);
            for (int p=2; p<=n; p++)
            {

               if(prime[p]==false)
               {
                   for(ll j=p+p;j<=100005;j+=p)
                   {
                       prime[j]=true;
                   }
               }
            }
            for(ll i=2;i<100005;i++)
            {
                if(!prime[i])
                {
                    // s.pb(i);
                    // t.insert(i);
                }
            }
        }
        void eea(ll a, ll b, ll & x, ll & y) {
        if (a == 0) {
            x = 0;
            y = 1;
            return ;
        }
        ll x1, y1;
        eea(b % a, a, x1, y1);
        x = y1 - (b / a) * x1;
        y = x1;
        return ;
    }
    ll modinverse(ll a,ll m)
    {
        ll x, y;
        eea(a, m, x, y);
        if (__gcd(a,m) != 1) {
        return -1;
        }
    else {
        x = (x % m + m) % m;
        cout << x << endl;
        return x;
    }
    }
//         ll fact[1000007]={0};
//         ll expo(ll x, ll y) {ll res=1;x=x%MOD;while(y>0){if(y&1)res=(1ll*res*x)%MOD;
//         y=y>>1;x=(1ll*x*x)%MOD;} return res;}
//         void facto() {fact[0]=1;fact[1]=1;for(ll i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%MOD;}
//         ll npr(ll n,ll r) {facto(); ll res=1; res=fact[n]; res=(res*(expo(fact[n-r],MOD-2)))%MOD; return res; }
//         ll ncr(ll n,ll r){ ll res=1; if(r>n-r)r=n-r; for(ll i=0;i<r;i++) {  res*=n-i;  res/=i+1; } return res;}
//             ll C(ll n, ll k) {
//     ll res = 1;
//     for (ll i = 1; i <= k; ++i)
//         res = ((res) * (n - k + i) / i)%MOD;
//     return (ll)(res + 0.01)%MOD;
// }
const int N=1e5+5;
  vector<int>v[N];
  int dp[N];
        int main()
        {
            fast
            // SieveOfEratosthenes();
        //    ct
			 {

                 for(ll i=2;i<=100005;i++)
                 {
                     for(ll j=i;j<=100005;j+=i)
                     {
                         v[j].pb(i);
                     }
                 }
                 int n;
                 cin>>n;
                 int a[n];
                 foe(0,n)
                 {
                     cin>>a[i];
                 }
                // memset(dp,0,sizeof(dp));
                int ans=0;
                 foe(0,n)
                 {
                     int m=0;
                     for(auto j:v[a[i]])
                     {
                         m=max(m,dp[j]);
                     }
                     for(auto j:v[a[i]])
                     {
                         dp[j]=m+1;
                     }
                     ans=max(ans,m+1);
                 }
                 cout<<ans<<"\n";
             }
        }


#include<bits/stdc++.h>
using namespace std;
long long mod = 1e9+7;
const long long inf = 2e18;
int n, ar[100005] = {};
int dp[100005] = {};
int factor[100005] = {};
void solve()
{
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        cin >> ar[i];
    }
    int ans = 1;
    for(int i = 1; i <= n; i++)
    {
        int x = ar[i];
        //cout << x << endl;
        vector<int>v;
        for(int j = 2; j*j <= x; j++)
        {
            if(x%j == 0)
            {
                v.push_back(j);
                factor[j]++;
                while(x%j == 0)
                {
                    //cout << x << endl;
                    x /= j;
                }
            }
        }
        if(x > 1)
        {
            v.push_back(x);
            factor[x]++;
        }
        int Max = 0;
        for(int j = 0; j < v.size(); j++)
        {
            Max = max(Max, factor[v[j]]);
        }
        for(int j = 0; j < v.size(); j++)
        {
            factor[v[j]] = Max;
        }
        dp[i] = Max;
        ans = max(ans, Max);
    }
    cout << ans << endl;
}
int main()
{
    solve();
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long mod = 1e9+7;
const long long inf = 2e18;
int n, ar[100005] = {};
int factor[100005] = {};
void solve()
{
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        cin >> ar[i];
    }
    int ans = 1;
    for(int i = 1; i <= n; i++)
    {
        int x = ar[i];
        vector<int>v;
        for(int j = 2; j*j <= x; j++)
        {
            if(x%j == 0)
            {
                v.push_back(j);
                factor[j]++;
                while(x%j == 0)
                {
                    x /= j;
                }
            }
        }
        if(x > 1)
        {
            v.push_back(x);
            factor[x]++;
        }
        int Max = 0;
        for(int j = 0; j < v.size(); j++)
        {
            Max = max(Max, factor[v[j]]);
        }
        for(int j = 0; j < v.size(); j++)
        {
            factor[v[j]] = Max;
        }
        ans = max(ans, Max);
    }
    cout << ans << endl;
}
int main()
{
    solve();
    return 0;
}


#include <bits/stdc++.h>
#define endl ("\n")
#define deb(x) cerr << (#x) << "=" << x << endl;
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed;
    cout.precision(10);
    // Those who cannot acknowledge themselves, will invariably fail

    int n;
    cin >> n;
    const int upper = 1e5 + 1;
    int arr[n];
    for(int i =0 ;i < n;i++)
    {
        cin >> arr[i];
    }
    int dp[upper] = {0};
    for(int i = 0;i < n;i++)
    {
        int sol = 1;
        for(int j = 1;j*j <= arr[i];j++)
        {
            if(arr[i]%j == 0)
            {
                if(j != 1)
                    sol = max(sol, dp[j] + 1);
                if(arr[i]/j != 1)
                    sol = max(sol, dp[arr[i]/j] + 1);
            }
        }
        for(int j = 1;j*j <= arr[i];j++)
        {
            if(arr[i]%j == 0)
            {
                if(j != 1)
                {
                    dp[j] = max(dp[j], sol);
                }
                if(arr[i]/j != 1)
                {
                    dp[arr[i]/j] = max(dp[arr[i]/j], sol);
                }
            }
        }
    }
    cout << *max_element(dp, dp + upper);
    return 0;
}


#include <bits/stdc++.h>
#define endl ("\n")
#define deb(x) cerr << (#x) << "=" << x << endl;
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed;
    cout.precision(10);
    // Those who cannot acknowledge themselves, will invariably fail

    int n;
    cin >> n;
    const int upper = 1e5 + 1;
    int arr[n];
    for(int i =0 ;i < n;i++)
    {
        cin >> arr[i];
    }
    int dp[upper] = {0};
    for(int i = 0;i < n;i++)
    {
        int sol = 1;
        for(int j = 1;j*j <= arr[i];j++)
        {
            if(arr[i]%j == 0)
            {
                if(j != 1)
                    sol = max(sol, dp[j] + 1);
                if(arr[i]/j != 1)
                    sol = max(sol, dp[arr[i]/j] + 1);
            }
        }
        for(int j = 1;j*j <= arr[i];j++)
        {
            if(arr[i]%j == 0)
            {
                if(j != 1)
                {
                    dp[j] = max(dp[j], sol);
                }
                if(arr[i]/j != 1)
                {
                    dp[arr[i]/j] = max(dp[arr[i]/j], sol);
                }
            }
        }
    }
    if(n == 1 and arr[0] == 1)
    {
        cout << arr[0];
    }
    else
    cout << *max_element(dp, dp + upper);
    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
//<DEFINE>
void Fast() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
}
void File() {
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#ifdef _WIN64
#define __builtin_popcountll __popcnt64
#else
inline int __builtin_popcountll(__int64 a) {
	return __builtin_popcount((unsigned int)a) + __builtin_popcount(a >> 32);
}
#endif
#endif
using ll = long long;
using ull = unsigned long long;
#define mod 1000000007
ll gcd(ll a, ll b) {
	return!b ? a : gcd(b, a % b);
}
#define fix(n) cout << fixed << setprecision(n);
#define all(a) a.begin(), a.end()
#define skip continue
#define stop(n) return cout<<n,0
#define pi  acos(-1)
#define TC int t;cin>>t;while(t--)
#define endl "\n"
#define ceil(x,y) (x+y-1)/y
//be careful from the multiplication while using this define
//</DEFINE>
const int N = 100001;
bool prime[N];
vector<int>v, primes;
vector<vector<int>>numFactors;
//<FUNCTIONS>
void  sieve() {
	for (int i = 0; i < N; i++)
		prime[i] = 1;
	prime[0] = prime[1] = 0;
	for (int i = 4; i < N; i += 2) {
		prime[i] = 0;
	}
	for (int i = 3; i * i < N; i += 2) {
		if (prime[i]) {
			for (int j = i * i; j < N; j += i + i) {
				prime[j] = 0;
			}
		}
	}
	for (int i = 2; i < N; i++) {
		if (prime[i]) {
			primes.push_back(i);
		}
	}
}
void Prime_Factors_Faster(int n) {
	int temp = n;
	if (prime[n]) {
		numFactors[temp].push_back(n);
		return;
	}
	int idx = 0;
	while (idx < primes.size() && primes[idx] * primes[idx] <= n) {
		int cnt = 0;
		while (n % primes[idx] == 0) {
			n /= primes[idx];
			cnt++;
		}
		if (cnt)numFactors[temp].push_back(primes[idx]);
		idx++;
	}
	if (n > 1) numFactors[temp].push_back(n);
}
//</FUNCTIONS>
int dp[100001];
int main() {
	File(), Fast();
	sieve();
	int n, x;
	numFactors.resize(1e5 + 1);
	cin >> n;
	int mx = 0;
	while (n--) {
		cin >> x;
		Prime_Factors_Faster(x);
		for (int i = 0; i < numFactors[x].size(); i++)dp[x] = max(dp[x], dp[numFactors[x][i]] + 1);
		for (int i = 0; i < numFactors[x].size(); i++)dp[numFactors[x][i]] = dp[x], mx = max(mx, dp[x]);
	}
	cout << mx << endl;
}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
//<DEFINE>
void Fast() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
}
void File() {
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#ifdef _WIN64
#define __builtin_popcountll __popcnt64
#else
inline int __builtin_popcountll(__int64 a) {
	return __builtin_popcount((unsigned int)a) + __builtin_popcount(a >> 32);
}
#endif
#endif
using ll = long long;
using ull = unsigned long long;
#define mod 1000000007
ll gcd(ll a, ll b) {
	return!b ? a : gcd(b, a % b);
}
#define fix(n) cout << fixed << setprecision(n);
#define all(a) a.begin(), a.end()
#define skip continue
#define stop(n) return cout<<n,0
#define pi  acos(-1)
#define TC int t;cin>>t;while(t--)
#define endl "\n"
#define ceil(x,y) (x+y-1)/y
//be careful from the multiplication while using this define
//</DEFINE>
const int N = 100001;
bool prime[N];
vector<int>v, primes;
vector<vector<int>>numFactors;
//<FUNCTIONS>
void  sieve() {
	for (int i = 0; i < N; i++)
		prime[i] = 1;
	prime[0] = prime[1] = 0;
	for (int i = 4; i < N; i += 2) {
		prime[i] = 0;
	}
	for (int i = 3; i * i < N; i += 2) {
		if (prime[i]) {
			for (int j = i * i; j < N; j += i + i) {
				prime[j] = 0;
			}
		}
	}
	for (int i = 2; i < N; i++) {
		if (prime[i]) {
			primes.push_back(i);
		}
	}
}
void Prime_Factors_Faster(int n) {
	int temp = n;
	if (prime[n]) {
		numFactors[temp].push_back(n);
		return;
	}
	int idx = 0;
	while (idx < primes.size() && primes[idx] * primes[idx] <= n) {
		int cnt = 0;
		while (n % primes[idx] == 0) {
			n /= primes[idx];
			cnt++;
		}
		if (cnt)numFactors[temp].push_back(primes[idx]);
		idx++;
	}
	if (n > 1) numFactors[temp].push_back(n);
}
//</FUNCTIONS>
int dp[100001];
int main() {
	File(), Fast();
	sieve();
	int n, x;
	numFactors.resize(1e5 + 1);
	cin >> n;
	while (n--) {
		cin >> x;
		Prime_Factors_Faster(x);
		for (int i = 0; i < numFactors[x].size(); i++)dp[x] = max(dp[x], dp[numFactors[x][i]] + 1);
		for (int i = 0; i < numFactors[x].size(); i++)dp[numFactors[x][i]] = dp[x];
	}
	cout << max(*max_element(dp, dp + 100001),1) << endl;
}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
//<DEFINE>
void Fast() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
}
void File() {
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#ifdef _WIN64
#define __builtin_popcountll __popcnt64
#else
inline int __builtin_popcountll(__int64 a) {
	return __builtin_popcount((unsigned int)a) + __builtin_popcount(a >> 32);
}
#endif
#endif
using ll = long long;
using ull = unsigned long long;
#define mod 1000000007
ll gcd(ll a, ll b) {
	return!b ? a : gcd(b, a % b);
}
#define fix(n) cout << fixed << setprecision(n);
#define all(a) a.begin(), a.end()
#define skip continue
#define stop(n) return cout<<n,0
#define pi  acos(-1)
#define TC int t;cin>>t;while(t--)
#define endl "\n"
#define ceil(x,y) (x+y-1)/y
//be careful from the multiplication while using this define
//</DEFINE>
//***********𝓢𝓣𝓞𝓟 𝓦𝓗𝓔𝓝 𝓨𝓞𝓤 𝓡𝓔𝓐𝓒𝓗 𝓣𝓗𝓔 𝓒𝓞𝓝𝓒𝓔𝓟𝓣 𝓞𝓕 𝓓𝓞𝓝'𝓣 𝓢𝓣𝓞𝓟***********//
const int N = 100001;
bool prime[N];
int n, res[N];
vector<int>v, primes;
//<FUNCTIONS>
vector<vector<int>>numFactors, primeIdx;
vector<int>::iterator it;
void  sieve() {
	for (int i = 0; i < N; i++)
		prime[i] = 1;
	prime[0] = prime[1] = 0;
	for (int i = 4; i < N; i += 2) {
		prime[i] = 0;
	}
	for (int i = 3; i * i < N; i += 2) {
		if (prime[i]) {
			for (int j = i * i; j < N; j += i + i) {
				prime[j] = 0;
			}
		}
	}
	for (int i = 2; i < N; i++) {
		if (prime[i]) {
			primes.push_back(i);
		}
	}
}
void Prime_Factors_Faster(int n, int id) {
	int temp = n;
	if (prime[n]) {
		primeIdx[n].push_back(id);
		numFactors[temp].push_back(n);
		return;
	}
	int idx = 0;
	while (idx < primes.size() && primes[idx] * primes[idx] <= n) {
		int cnt = 0;
		while (n % primes[idx] == 0) {
			n /= primes[idx];
			cnt++;
		}
		if (cnt)numFactors[temp].push_back(primes[idx]), primeIdx[primes[idx]].push_back(id);;
		idx++;
	}
	if (n > 1) {
		primeIdx[n].push_back(id);
		numFactors[temp].push_back(n);
	}
}
int solve(int idx) {
	int& ans = res[idx];
	if (~ans)return ans;
	ans = 1;
	for (int i = 0; i < numFactors[v[idx]].size(); i++) {
		int pr = numFactors[v[idx]][i];
		it = upper_bound(all(primeIdx[pr]), idx);
		if (it != primeIdx[pr].end())ans = max(ans, solve(*it) + 1);
	}
	return ans;
}
//</FUNCTIONS>
int main() {
	File(), Fast();
	sieve();
	numFactors.resize(N), primeIdx.resize(N);
	cin >> n;
	v.resize(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i], Prime_Factors_Faster(v[i], i);
	}
	int* dp = new int[n];
	for (int i = 0; i < n; i++)dp[i] = 1;
	for (int i = 0; i < n; i++)cin >> v[i], Prime_Factors_Faster(v[i], i);
	for (int i = n - 1; i >= 0; i--) {
		for (int j = 0; j < numFactors[v[i]].size(); j++) {
			int pr = numFactors[v[i]][j];
			it = upper_bound(all(primeIdx[pr]), i);
			if (it != primeIdx[pr].end() and v[*it] > v[i])dp[i] = max(dp[i], dp[*it] + 1);
		}
	}
	cout << *max_element(dp, dp + n) << endl;
}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
//<DEFINE>
void Fast() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
}
void File() {
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#ifdef _WIN64
#define __builtin_popcountll __popcnt64
#else
inline int __builtin_popcountll(__int64 a) {
	return __builtin_popcount((unsigned int)a) + __builtin_popcount(a >> 32);
}
#endif
#endif
using ll = long long;
using ull = unsigned long long;
#define mod 1000000007
ll gcd(ll a, ll b) {
	return!b ? a : gcd(b, a % b);
}
#define fix(n) cout << fixed << setprecision(n);
#define all(a) a.begin(), a.end()
#define skip continue
#define stop(n) return cout<<n,0
#define pi  acos(-1)
#define TC int t;cin>>t;while(t--)
#define endl "\n"
#define ceil(x,y) (x+y-1)/y
//be careful from the multiplication while using this define
//</DEFINE>
//<FUNCTIONS>
//</FUNCTIONS>
int dp[100001];
int main() {
	File(), Fast();
	int n, x;
	cin >> n;
	while (n--) {
		cin >> x;
		dp[x] = 1;
		for (ll i = 2; i * i <= x; i++) {
			if (!(x % i)) {
				dp[x] = max({ dp[x], dp[i] + 1, dp[x / i] + 1 });
			}
		}
		for (ll i = 2; i * i <= x; i++) {
			if (!(x % i)) {
				dp[i] = dp[x / i] = dp[x];
			}
		}
	}
	cout << *max_element(dp, dp + 100001) << endl;
}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
//<DEFINE>
void Fast() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
}
void File() {
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#ifdef _WIN64
#define __builtin_popcountll __popcnt64
#else
inline int __builtin_popcountll(__int64 a) {
	return __builtin_popcount((unsigned int)a) + __builtin_popcount(a >> 32);
}
#endif
#endif
using ll = long long;
using ull = unsigned long long;
#define mod 1000000007
ll gcd(ll a, ll b) {
	return!b ? a : gcd(b, a % b);
}
#define fix(n) cout << fixed << setprecision(n);
#define all(a) a.begin(), a.end()
#define skip continue
#define stop(n) return cout<<n,0
#define pi  acos(-1)
#define TC int t;cin>>t;while(t--)
#define endl "\n"
#define ceil(x,y) (x+y-1)/y
//be careful from the multiplication while using this define
//</DEFINE>
//***********𝓢𝓣𝓞𝓟 𝓦𝓗𝓔𝓝 𝓨𝓞𝓤 𝓡𝓔𝓐𝓒𝓗 𝓣𝓗𝓔 𝓒𝓞𝓝𝓒𝓔𝓟𝓣 𝓞𝓕 𝓓𝓞𝓝'𝓣 𝓢𝓣𝓞𝓟***********//
const int N = 100001;
bool prime[N];
int n,res[N];
vector<int>v, primes;
//<FUNCTIONS>
vector<vector<int>>numFactors,primeIdx;
vector<int>::iterator it;
void  sieve() {
	for (int i = 0; i < N; i++)
		prime[i] = 1;
	prime[0] = prime[1] = 0;
	for (int i = 4; i < N; i += 2) {
		prime[i] = 0;
	}
	for (int i = 3; i * i < N; i += 2) {
		if (prime[i]) {
			for (int j = i * i; j < N; j += i + i) {
				prime[j] = 0;
			}
		}
	}
	for (int i = 2; i < N; i++) {
		if (prime[i]) {
			primes.push_back(i);
		}
	}
}
void Prime_Factors_Faster(int n, int id) {
	int temp = n;
	if (prime[n]) {
		primeIdx[n].push_back(id);
		numFactors[temp].push_back(n);
		return;
	}
	int idx = 0;
	while (idx < primes.size() && primes[idx] * primes[idx] <= n) {
		int cnt = 0;
		while (n % primes[idx] == 0) {
			n /= primes[idx];
			cnt++;
		}
		if (cnt)numFactors[temp].push_back(primes[idx]), primeIdx[primes[idx]].push_back(id);;
		idx++;
	}
	if (n > 1) {
		primeIdx[n].push_back(id);
		numFactors[temp].push_back(n);
	}
}
int solve(int idx) {
	int& ans = res[idx];
	if (~ans)return ans;
	ans = 1;
	for (int i = 0; i < numFactors[v[idx]].size(); i++) {
		int pr = numFactors[v[idx]][i];
		it = upper_bound(all(primeIdx[pr]), idx);
		if (it != primeIdx[pr].end())ans = max(ans, solve(*it) + 1);
	}
	return ans;
}
//</FUNCTIONS>
int main() {
	File(), Fast();
	sieve();
	memset(res, -1, sizeof(res));
	numFactors.resize(N), primeIdx.resize(N);
	cin >> n;
	v.resize(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i], Prime_Factors_Faster(v[i], i);
	}
	int mx = 0;
	for (int i = 0; i < n; i++) {
		mx = max(mx, solve(i));
	}
	cout << mx << endl;
}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
//<DEFINE>
void Fast() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
}
void File() {
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#ifdef _WIN64
#define __builtin_popcountll __popcnt64
#else
inline int __builtin_popcountll(__int64 a) {
	return __builtin_popcount((unsigned int)a) + __builtin_popcount(a >> 32);
}
#endif
#endif
using ll = long long;
using ull = unsigned long long;
#define mod 1000000007
ll gcd(ll a, ll b) {
	return!b ? a : gcd(b, a % b);
}
#define fix(n) cout << fixed << setprecision(n);
#define all(a) a.begin(), a.end()
#define skip continue
#define stop(n) return cout<<n,0
#define pi  acos(-1)
#define TC int t;cin>>t;while(t--)
#define endl "\n"
#define ceil(x,y) (x+y-1)/y
//be careful from the multiplication while using this define
//</DEFINE>
//***********𝓢𝓣𝓞𝓟 𝓦𝓗𝓔𝓝 𝓨𝓞𝓤 𝓡𝓔𝓐𝓒𝓗 𝓣𝓗𝓔 𝓒𝓞𝓝𝓒𝓔𝓟𝓣 𝓞𝓕 𝓓𝓞𝓝'𝓣 𝓢𝓣𝓞𝓟***********//
const int N = 100001;
bool prime[N];
int n, res[N];
vector<int>v, primes;
//<FUNCTIONS>
vector<vector<int>>numFactors, primeIdx;
vector<int>::iterator it;
void  sieve() {
	for (int i = 0; i < N; i++)
		prime[i] = 1;
	prime[0] = prime[1] = 0;
	for (int i = 4; i < N; i += 2) {
		prime[i] = 0;
	}
	for (int i = 3; i * i < N; i += 2) {
		if (prime[i]) {
			for (int j = i * i; j < N; j += i + i) {
				prime[j] = 0;
			}
		}
	}
	for (int i = 2; i < N; i++) {
		if (prime[i]) {
			primes.push_back(i);
		}
	}
}
void Prime_Factors_Faster(int n, int id) {
	int temp = n;
	if (prime[n]) {
		primeIdx[n].push_back(id);
		numFactors[temp].push_back(n);
		return;
	}
	int idx = 0;
	while (idx < primes.size() && primes[idx] * primes[idx] <= n) {
		int cnt = 0;
		while (n % primes[idx] == 0) {
			n /= primes[idx];
			cnt++;
		}
		if (cnt)numFactors[temp].push_back(primes[idx]), primeIdx[primes[idx]].push_back(id);;
		idx++;
	}
	if (n > 1) {
		primeIdx[n].push_back(id);
		numFactors[temp].push_back(n);
	}
}
int solve(int idx) {
	int& ans = res[idx];
	if (~ans)return ans;
	ans = 1;
	for (int i = 0; i < numFactors[v[idx]].size(); i++) {
		int pr = numFactors[v[idx]][i];
		it = upper_bound(all(primeIdx[pr]), idx);
		if (it != primeIdx[pr].end())ans = max(ans, solve(*it) + 1);
	}
	return ans;
}
//</FUNCTIONS>
int main() {
	File(), Fast();
	sieve();
	numFactors.resize(N), primeIdx.resize(N);
	cin >> n;
	v.resize(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i], Prime_Factors_Faster(v[i], i);
	}
	int* dp = new int(n);
	for (int i = 0; i < n; i++)dp[i] = 1;
	for (int i = 0; i < n; i++)cin >> v[i], Prime_Factors_Faster(v[i], i);
	for (int i = n - 1; i >= 0; i--) {
		for (int j = 0; j < numFactors[v[i]].size(); j++) {
			int pr = numFactors[v[i]][j];
			it = upper_bound(all(primeIdx[pr]), i);
			if (it != primeIdx[pr].end() and v[*it] > v[i])dp[i] = max(dp[i], dp[*it] + 1);
		}
	}
	cout << *max_element(dp, dp + n) << endl;
}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
//<DEFINE>
void Fast() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
}
void File() {
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#ifdef _WIN64
#define __builtin_popcountll __popcnt64
#else
inline int __builtin_popcountll(__int64 a) {
	return __builtin_popcount((unsigned int)a) + __builtin_popcount(a >> 32);
}
#endif
#endif
using ll = long long;
using ull = unsigned long long;
#define mod 1000000007
ll gcd(ll a, ll b) {
	return!b ? a : gcd(b, a % b);
}
#define fix(n) cout << fixed << setprecision(n);
#define all(a) a.begin(), a.end()
#define skip continue
#define stop(n) return cout<<n,0
#define pi  acos(-1)
#define TC int t;cin>>t;while(t--)
#define endl "\n"
#define ceil(x,y) (x+y-1)/y
//be careful from the multiplication while using this define
//</DEFINE>
//***********𝓢𝓣𝓞𝓟 𝓦𝓗𝓔𝓝 𝓨𝓞𝓤 𝓡𝓔𝓐𝓒𝓗 𝓣𝓗𝓔 𝓒𝓞𝓝𝓒𝓔𝓟𝓣 𝓞𝓕 𝓓𝓞𝓝'𝓣 𝓢𝓣𝓞𝓟***********//
const int N = 100001;
bool prime[N];
int n,res[N];
vector<int>v;
//<FUNCTIONS>
vector<vector<int>>numFactors,primeIdx;
vector<int>::iterator it;
void  sieve() {
	for (int i = 0; i < N; i++)
		prime[i] = 1;
	prime[0] = prime[1] = 0;
	for (int i = 4; i < N; i += 2) {
		prime[i] = 0;
	}
	for (int i = 3; i * i < N; i += 2) {
		if (prime[i]) {
			for (int j = i * i; j < N; j += i + i) {
				prime[j] = 0;
			}
		}
	}
}
void Prime_Factors_Faster(int n, int id) {
	int temp = n;
	vector<int>primes;
	for (int i = 2; i < N; i++) {
		if (prime[i]) {
			primes.push_back(i);
		}
	}
	if (prime[n]) {
		primeIdx[n].push_back(id);
		numFactors[temp].push_back(n);
		return;
	}
	int idx = 0;
	while (idx < primes.size() && primes[idx] * primes[idx] <= n) {
		int cnt = 0;
		while (n % primes[idx] == 0) {
			n /= primes[idx];
			cnt++;
		}
		if (cnt)numFactors[temp].push_back(primes[idx]), primeIdx[primes[idx]].push_back(id);;
		idx++;
	}
	if (n > 1) {
		primeIdx[n].push_back(id);
		numFactors[temp].push_back(n);
	}
}
int solve(int idx) {
	int& ans = res[idx];
	if (~ans)return ans;
	ans = 1;
	for (int i = 0; i < numFactors[v[idx]].size(); i++) {
		int pr = numFactors[v[idx]][i];
		it = upper_bound(all(primeIdx[pr]), idx);
		if (it != primeIdx[pr].end())ans = max(ans, solve(*it) + 1);
	}
	return ans;
}
//</FUNCTIONS>
int main() {
	File(), Fast();
	sieve();
	memset(res, -1, sizeof(res));
	numFactors.resize(N), primeIdx.resize(N);
	cin >> n;
	v.resize(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i], Prime_Factors_Faster(v[i], i);
	}
	int mx = 0;
	for (int i = 0; i < n; i++) {
		mx = max(mx, solve(i));
	}
	cout << mx << endl;
}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
//<DEFINE>
void Fast() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
}
void File() {
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#ifdef _WIN64
#define __builtin_popcountll __popcnt64
#else
inline int __builtin_popcountll(__int64 a) {
	return __builtin_popcount((unsigned int)a) + __builtin_popcount(a >> 32);
}
#endif
#endif
using ll = long long;
using ull = unsigned long long;
#define mod 1000000007
ll gcd(ll a, ll b) {
	return!b ? a : gcd(b, a % b);
}
#define fix(n) cout << fixed << setprecision(n);
#define all(a) a.begin(), a.end()
#define skip continue
#define stop(n) return cout<<n,0
#define pi  acos(-1)
#define TC int t;cin>>t;while(t--)
#define endl "\n"
#define ceil(x,y) (x+y-1)/y
//be careful from the multiplication while using this define
//</DEFINE>
const int N = 100001;
bool prime[N];
vector<int>v, primes;
vector<vector<int>>numFactors;
//<FUNCTIONS>
void  sieve() {
	for (int i = 0; i < N; i++)
		prime[i] = 1;
	prime[0] = prime[1] = 0;
	for (int i = 4; i < N; i += 2) {
		prime[i] = 0;
	}
	for (int i = 3; i * i < N; i += 2) {
		if (prime[i]) {
			for (int j = i * i; j < N; j += i + i) {
				prime[j] = 0;
			}
		}
	}
	for (int i = 2; i < N; i++) {
		if (prime[i]) {
			primes.push_back(i);
		}
	}
}
void Prime_Factors_Faster(int n) {
	int temp = n;
	if (prime[n]) {
		numFactors[temp].push_back(n);
		return;
	}
	int idx = 0;
	while (idx < primes.size() && primes[idx] * primes[idx] <= n) {
		int cnt = 0;
		while (n % primes[idx] == 0) {
			n /= primes[idx];
			cnt++;
		}
		if (cnt)numFactors[temp].push_back(primes[idx]);
		idx++;
	}
	if (n > 1) numFactors[temp].push_back(n);
}
//</FUNCTIONS>
int dp[100001];
int main() {
	File(), Fast();
	sieve();
	int n, x;
	numFactors.resize(1e5 + 1);
	cin >> n;
	int mx = 0;
	while (n--) {
		cin >> x;
		Prime_Factors_Faster(x);
		for (int i = 0; i < numFactors[x].size(); i++)dp[x] = max(dp[x], dp[numFactors[x][i]] + 1);
		for (int i = 0; i < numFactors[x].size(); i++)dp[numFactors[x][i]] = dp[x], mx = max(mx, dp[x]);
	}
	cout << max(mx, 1) << endl;
}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
//<DEFINE>
void Fast() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
}
void File() {
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#ifdef _WIN64
#define __builtin_popcountll __popcnt64
#else
inline int __builtin_popcountll(__int64 a) {
	return __builtin_popcount((unsigned int)a) + __builtin_popcount(a >> 32);
}
#endif
#endif
using ll = long long;
using ull = unsigned long long;
#define mod 1000000007
ll gcd(ll a, ll b) {
	return!b ? a : gcd(b, a % b);
}
#define fix(n) cout << fixed << setprecision(n);
#define all(a) a.begin(), a.end()
#define skip continue
#define stop(n) return cout<<n,0
#define pi  acos(-1)
#define TC int t;cin>>t;while(t--)
#define endl "\n"
#define ceil(x,y) (x+y-1)/y
//be careful from the multiplication while using this define
//</DEFINE>
//***********𝓢𝓣𝓞𝓟 𝓦𝓗𝓔𝓝 𝓨𝓞𝓤 𝓡𝓔𝓐𝓒𝓗 𝓣𝓗𝓔 𝓒𝓞𝓝𝓒𝓔𝓟𝓣 𝓞𝓕 𝓓𝓞𝓝'𝓣 𝓢𝓣𝓞𝓟***********//
const int N = 100001;
bool prime[N];
vector<int>primes;
vector<vector<int>>numFactors, primeIdx;
//<FUNCTIONS>
void  sieve() {
	for (int i = 0; i < N; i++)
		prime[i] = 1;
	prime[0] = prime[1] = 0;
	for (int i = 4; i < N; i += 2) {
		prime[i] = 0;
	}
	for (int i = 3; i * i < N; i += 2) {
		if (prime[i]) {
			for (int j = i * i; j < N; j += i + i) {
				prime[j] = 0;
			}
		}
	}
	for (int i = 2; i < N; i++) {
		if (prime[i]) {
			primes.push_back(i);
		}
	}
}
void Prime_Factors_Faster(int n, int id) {
	int temp = n;
	if (prime[n]) {
		primeIdx[n].push_back(id);
		numFactors[temp].push_back(n);
		return;
	}
	int idx = 0;
	while (idx < primes.size() && primes[idx] * primes[idx] <= n) {
		int cnt = 0;
		while (n % primes[idx] == 0) {
			n /= primes[idx];
			cnt++;
		}
		if (cnt)numFactors[temp].push_back(primes[idx]), primeIdx[primes[idx]].push_back(id);;
		idx++;
	}
	if (n > 1) {
		primeIdx[n].push_back(id);
		numFactors[temp].push_back(n);
	}
}
//</FUNCTIONS>
int main() {
	File(), Fast();
	sieve();
	int n;
	numFactors.resize(N), primeIdx.resize(N);
	cin >> n;
	vector<int>v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i], Prime_Factors_Faster(v[i], i);
	}
	int* dp = new int[n];
	vector<int>::iterator it;
	for (int i = 0; i < n; i++)dp[i] = 1;
	for (int i = 0; i < n; i++)cin >> v[i], Prime_Factors_Faster(v[i], i);
	for (int i = n - 1; i >= 0; i--) {
		for (int j = 0; j < numFactors[v[i]].size(); j++) {
			int pr = numFactors[v[i]][j];
			it = upper_bound(all(primeIdx[pr]), i);
			if (it != primeIdx[pr].end() and v[*it] > v[i])dp[i] = max(dp[i], dp[*it] + 1);
		}
	}
	cout << *max_element(dp, dp + n) << endl;
}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
//<DEFINE>
void Fast() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
}
void File() {
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#ifdef _WIN64
#define __builtin_popcountll __popcnt64
#else
inline int __builtin_popcountll(__int64 a) {
	return __builtin_popcount((unsigned int)a) + __builtin_popcount(a >> 32);
}
#endif
#endif
using ll = long long;
using ull = unsigned long long;
#define mod 1000000007
ll gcd(ll a, ll b) {
	return!b ? a : gcd(b, a % b);
}
#define fix(n) cout << fixed << setprecision(n);
#define all(a) a.begin(), a.end()
#define skip continue
#define stop(n) return cout<<n,0
#define pi  acos(-1)
#define TC int t;cin>>t;while(t--)
#define endl "\n"
#define ceil(x,y) (x+y-1)/y
//be careful from the multiplication while using this define
//</DEFINE>
const int N = 100001;
bool prime[N];
vector<int>v, primes;
vector<vector<int>>numFactors;
//<FUNCTIONS>
void  sieve() {
	for (int i = 0; i < N; i++)
		prime[i] = 1;
	prime[0] = prime[1] = 0;
	for (int i = 4; i < N; i += 2) {
		prime[i] = 0;
	}
	for (int i = 3; i * i < N; i += 2) {
		if (prime[i]) {
			for (int j = i * i; j < N; j += i + i) {
				prime[j] = 0;
			}
		}
	}
	for (int i = 2; i < N; i++) {
		if (prime[i]) {
			primes.push_back(i);
		}
	}
}
void Prime_Factors_Faster(int n) {
	int temp = n;
	if (prime[n]) {
		numFactors[temp].push_back(n);
		return;
	}
	int idx = 0;
	while (idx < primes.size() && primes[idx] * primes[idx] <= n) {
		int cnt = 0;
		while (n % primes[idx] == 0) {
			n /= primes[idx];
			cnt++;
		}
		if (cnt)numFactors[temp].push_back(primes[idx]);
		idx++;
	}
	if (n > 1) numFactors[temp].push_back(n);
}
//</FUNCTIONS>
int dp[100001];
int main() {
	File(), Fast();
	sieve();
	int n, x;
	numFactors.resize(1e5 + 1);
	cin >> n;
	while (n--) {
		cin >> x;
		Prime_Factors_Faster(x);
		for (int i = 0; i < numFactors[x].size(); i++)dp[x] = max(dp[x], dp[numFactors[x][i]] + 1);
		for (int i = 0; i < numFactors[x].size(); i++)dp[numFactors[x][i]] = dp[x];
	}
	cout << *max_element(dp, dp + 100001) << endl;
}


#include <bits/stdc++.h>
#define F first
#define S second
#define all(a) a.begin(),a.end()
#define setDP(arr) memset(arr,-1,sizeof arr)
#define Clear(arr) memset(arr,0,sizeof arr)
#define li(x) x.size()-1
#define oo 2000000000
#define inf 1000000000000000000
#define M 1000000007
typedef long long ll;
using namespace std;
const int N =2e5+10;
const int SQRTN = 320;
const int LOGN = 20;

int n , a[N],dp[N];
vector<int> f;
int mx[N];
vector<int> prime;
bool notPrime[N];
void seive(){
    notPrime[1]=1;
    for(int i = 2 ; i < N ; i++){
        if(!notPrime[i]){
            for(int j = i+i ; j <N ; j+=i)
                notPrime[j]=1;
            prime.push_back(i);
        }
    }
}
void get(int a){
    f.clear();
    for(int i = 0 ; prime[i]*prime[i] <= a ; i++){
        if(a%prime[i])continue;
        f.push_back(prime[i]);
        if(prime[i]*prime[i]!=a)
            if(!notPrime[a/prime[i]])
                f.push_back(a/prime[i]);
    }
    if(!notPrime[a])f.push_back(a);
}

void add(int idx){
    for(int i = 0 ; i < f.size() ; i++)mx[f[i]]=max(mx[f[i]],dp[idx]);
}
int mxx =0;
int main() {
    #ifndef ONLINE_JUDGE
        freopen("in.txt","r",stdin);
    #endif
    scanf("%d",&n);
    seive();
    for(int i = 0 ; i < n ; i++)scanf("%d",a+i);
    for(int i = 0 ; i < n ; i++){
        dp[i]=1;
        get(a[i]);
        for(int j = 0 ; j < f.size() ; j++)
                dp[i]=max(dp[i],mx[f[j]]+1);
        mxx = max(mxx,dp[i]);
        add(i);
    }

    cout << mxx << endl;

}


#include <bits/stdc++.h>
#define F first
#define S second
#define all(a) a.begin(),a.end()
#define setDP(arr) memset(arr,-1,sizeof arr)
#define Clear(arr) memset(arr,0,sizeof arr)
#define li(x) x.size()-1
#define oo 2000000000
#define inf 1000000000000000000
#define M 1000000007
typedef long long ll;
using namespace std;
const int N =1e5+10;
const int SQRTN = 320;
const int LOGN = 20;

int n , a[N],dp[N];
vector<int> f;
int mx[N];
vector<int> prime;
bool notPrime[N];
void seive(){
    notPrime[1]=1;
    for(int i = 2 ; i < N ; i++){
        if(!notPrime[i]){
            for(int j = i+i ; j <N ; j+=i)
                notPrime[j]=1;
            prime.push_back(i);
        }
    }
}
void get(int a){
    f.clear();
    for(int i = 0 ; prime[i]*prime[i] <= a ; i++){
        if(a%prime[i])continue;
        f.push_back(prime[i]);
        if(prime[i]*prime[i]!=a)
            if(!notPrime[a/prime[i]])
                f.push_back(a/prime[i]);
    }
    if(!notPrime[a])f.push_back(a);
}

void add(int idx){
    for(int i = 0 ; i < f.size() ; i++)mx[f[i]]=max(mx[f[i]],dp[idx]);
}
int mxx =0;
int main() {
    #ifndef ONLINE_JUDGE
        freopen("in.txt","r",stdin);
    #endif
    scanf("%d",&n);
    seive();
    for(int i = 0 ; i < n ; i++)scanf("%d",a+i);
    for(int i = 0 ; i < n ; i++){
        dp[i]=1;
        get(a[i]);
        for(int j = 0 ; j < f.size() ; j++)
                dp[i]=max(dp[i],mx[f[j]]+1);
        mxx = max(mxx,dp[i]);
        add(i);
    }

    cout << mxx << endl;

}


#include <bits/stdc++.h>
#define F first
#define S second
#define all(a) a.begin(),a.end()
#define setDP(arr) memset(arr,-1,sizeof arr)
#define Clear(arr) memset(arr,0,sizeof arr)
#define li(x) x.size()-1
#define oo 2000000000
#define inf 1000000000000000000
#define M 1000000007
typedef long long ll;
using namespace std;
const int N =1e5+10;
const int SQRTN = 320;
const int LOGN = 20;

int n , a[N],dp[N];
vector<int> f;
vector<int> fo[N];
vector<int> prime;
bool notPrime[N];
void seive(){
    notPrime[1]=1;
    for(int i = 2 ; i < N ; i++){
        if(!notPrime[i]){
            for(int j = i+i ; j <N ; j+=i)
                notPrime[j]=1;
            prime.push_back(i);
        }
    }
}
void get(int a){
    f.clear();
    for(int i = 0 ; prime[i]*prime[i] <= a ; i++){
        if(a%prime[i])continue;
        f.push_back(prime[i]);
        if(prime[i]*prime[i]!=a)
            if(!notPrime[a/prime[i]])
                f.push_back(a/prime[i]);
    }
    if(!notPrime[a])f.push_back(a);
}

void add(int a,int idx){
    for(int i = 0 ; prime[i]*prime[i] <= a ; i++){
        if(a%prime[i])continue;
        fo[prime[i]].push_back(idx);
        if(prime[i]*prime[i]!=a)
            if(!notPrime[a/prime[i]])
                fo[a/prime[i]].push_back(idx);
    }
    if(!notPrime[a])fo[a].push_back(idx);
}
int mx =0;
int main() {
    #ifndef ONLINE_JUDGE
        freopen("in.txt","r",stdin);
    #endif
    scanf("%d",&n);
    seive();
    for(int i = 0 ; i < n ; i++)scanf("%d",a+i);
    for(int i = 0 ; i < n ; i++){
        dp[i]=1;
        get(a[i]);
        for(int j = 0 ; j < f.size() ; j++){
            for(int k = 0 ; k < fo[f[j]].size() ; k++){
                dp[i]=max(dp[i],dp[fo[f[j]][k]]+1);
            }
        }
        mx = max(mx,dp[i]);
        add(a[i],i);

    }

    cout << mx << endl;

}


#include <bits/stdc++.h>
#define F first
#define S second
#define all(a) a.begin(),a.end()
#define setDP(arr) memset(arr,-1,sizeof arr)
#define Clear(arr) memset(arr,0,sizeof arr)
#define li(x) x.size()-1
#define oo 2000000000
#define inf 1000000000000000000
#define M 1000000007
typedef long long ll;
using namespace std;
const int N =2e5+10;
const int SQRTN = 320;
const int LOGN = 20;

int n , a[N],dp[N];
vector<int> f;
int mx[N];
vector<int> prime;
bool notPrime[N];

void seive(){
    notPrime[1]=1;
    for(int i = 2 ; i < N ; i++)
        if(!notPrime[i]){
            for(int j = i+i ; j <N ; j+=i)
                notPrime[j]=1;
            prime.push_back(i);
        }
}

void get(int a){
    f.clear();
    for(int i = 2 ; i*i<=a ; i++){
        if(a%i)continue;
        f.push_back(i);
        while(a%i==0)a/=i;
    }
    if(a!=1)f.push_back(a);
}

void add(int idx){
    for(int i = 0 ; i < f.size() ; i++)mx[f[i]]=max(mx[f[i]],dp[idx]);
}

int mxx =0;

int main() {
    #ifndef ONLINE_JUDGE
        freopen("in.txt","r",stdin);
    #endif
    scanf("%d",&n);
    seive();
    for(int i = 0 ; i < n ; i++)scanf("%d",a+i);
    for(int i = 0 ; i < n ; i++){
        dp[i]=1;
        get(a[i]);
        for(int j = 0 ; j < f.size() ; j++)
                dp[i]=max(dp[i],mx[f[j]]+1);
        mxx = max(mxx,dp[i]);
        add(i);
    }

    cout << mxx << endl;

}


#include <bits/stdc++.h>

using namespace std;

#define int long long
#define ld1 long double
//#define cerr if(false)cerr
#define watch(x) cerr << (#x) << " is " << (x) << endl
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL),cout<<setprecision(14);
#define cint int t;cin>>t;while(t--)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define vint vector<int>
#define all(v) (v).begin(), (v).end()
#define pii pair<int,int>
#define pb push_back
#define N 100001
//using ld1=double;
#define mm0(X) memset((X), 0, sizeof((X)))
#define mm1(X) memset((X), -1, sizeof((X)))
vector<vint> adj;
int n,m;
//xenia

int32_t main() {
    faster;

    int n;
    cin>>n;
    int a[n]; for(int i=0;i<n;i++) cin>>a[i];

    int dp[n]={};

    int dp1[N];
    mm1(dp1);

    for(int i=0;i<n;i++){
        int x=a[i];
        for(int j=2;j*j<=x;j++){
            int y=0;
            while(x%j==0){
                x/=j; y=1;}
            if(!y) continue;
                if(dp1[j]==-1){
                    dp[i]=max(dp[i],1LL);
                    dp1[j]=i;
                    continue;
                }
                dp[i]=max(dp[i],dp[dp1[j]]+1);
//                if(j==2) cout<<"ehkj";
                dp1[j]=i;
        }
        if(x>1){
            if(dp1[x]==-1){
                dp[i]=max(dp[i],1LL);
                dp1[x]=i;
                continue;
            }
            dp[i]=max(dp[i],dp[dp1[x]]+1);
            dp1[x]=i;
        }
    }
//    cout<<dp[3]<<" ";
//    cout<<dp1[3]<<" ";
    int ans=0;
    for(int i=0;i<n;i++) {
//        cout<<dp[i]<<" ";
        ans=max(ans,dp[i]);
    }

    cout<<ans<<endl;
}


#include <bits/stdc++.h>

using namespace std;

#define int long long
#define ld1 long double
//#define cerr if(false)cerr
#define watch(x) cerr << (#x) << " is " << (x) << endl
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL),cout<<setprecision(14);
#define cint int t;cin>>t;while(t--)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define vint vector<int>
#define all(v) (v).begin(), (v).end()
#define pii pair<int,int>
#define pb push_back
#define N 100001
//using ld1=double;
#define mm0(X) memset((X), 0, sizeof((X)))
#define mm1(X) memset((X), -1, sizeof((X)))
vector<vint> adj;
int n,m;
//xenia

int32_t main() {
    faster;

    int n;
    cin>>n;
    int a[n]; for(int i=0;i<n;i++) cin>>a[i];

    if(n==1){
        cout<<1<<endl;
        return 0;
    }
    int dp[n];

    mm0(dp);
    int dp1[N];
    mm1(dp1);

    for(int i=0;i<n;i++){
        int x=a[i];
        for(int j=2;j*j<=x;j++){
            int y=0;
            while(x%j==0){
                x/=j; y=1;}
            if(!y) continue;
            if(dp1[j]==-1){
                dp[i]=max(dp[i],1LL);
                dp1[j]=i;
                continue;
            }
            dp[i]=max(dp[i],dp[dp1[j]]+1);
//                if(j==2) cout<<"ehkj";
            dp1[j]=i;
        }
        if(x>1){
            if(dp1[x]==-1){
                dp[i]=max(dp[i],1LL);
                dp1[x]=i;
                continue;
            }
            dp[i]=max(dp[i],dp[dp1[x]]+1);
            dp1[x]=i;
        }
    }

    int ans=0;
    for(int i=0;i<n;i++) {
//        cout<<dp[i]<<" ";
        ans=max(ans,dp[i]);
    }

    cout<<ans<<endl;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<pll,pll> ppll;
typedef long double ld;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fst first
#define snd second
#define ins insert
#define pb push_back

const int N = 5e5 + 5;
const int MOD = 1e9 + 7;
int a[N];
int ans[N];
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen(".in", "r", stdin);
    //freopen(".out", "w", stdout);
    int n;
    cin >> n;
    for(int i = 0;i < n; ++i){
        cin >> a[i];
    }
    for(int i = n - 1;i >= 0; --i){
            int mx = 0;
        for(int j = 1;j * j <= a[i]; ++j){
            if(a[i] % j == 0){
                if(j != 1)mx = max(ans[j],mx);
                mx = max(ans[a[i] / j],mx);
            }
        }
        for(int j = 1;j * j <= a[i]; ++j){
            if(a[i] % j == 0){
                ans[j] = max(ans[j],mx + 1);
                ans[a[i] / j] = max(ans[a[i] / j],mx + 1);
            }
        }
    }
    int mx = 0;
    for(int i = 2;i < N; ++i){
        mx = max(mx,ans[i]);
    }
    cout << mx;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<pll,pll> ppll;
typedef long double ld;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fst first
#define snd second
#define ins insert
#define pb push_back

const int N = 5e5 + 5;
const int MOD = 1e9 + 7;
ll a[N];
ll ans[N];
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen(".in", "r", stdin);
    //freopen(".out", "w", stdout);
    ll n;
    cin >> n;
    for(int i = 0;i < n; ++i){
        cin >> a[i];
    }
    for(int i = n - 1;i >= 0; --i){
        ll mx = 0;
        if(a[i] == 1)break;
        for(int j = 2;j * j <= a[i]; ++j){
            if(a[i] % j == 0){
                if(j != 1)mx = max(ans[j],mx);
                mx = max(ans[a[i] / j],mx);
            }
        }
        mx = max(mx,ans[a[i]]);
        for(int j = 2;j * j <= a[i]; ++j){
            if(a[i] % j == 0){
                ans[j] = max(ans[j],mx + 1);
                ans[a[i] / j] = max(ans[a[i] / j],mx + 1);
            }
        }
        ans[a[i]] = mx + 1;
    }
    ll mx = 1;
    for(int i = 2;i < N; ++i){
        mx = max(mx,ans[i]);
    }
    cout << mx;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<pll,pll> ppll;
typedef long double ld;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fst first
#define snd second
#define ins insert
#define pb push_back

const int N = 5e5 + 5;
const int MOD = 1e9 + 7;
ll a[N];
ll ans[N];
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen(".in", "r", stdin);
    //freopen(".out", "w", stdout);
    ll n;
    cin >> n;
    for(int i = 0;i < n; ++i){
        cin >> a[i];
    }
    for(int i = n - 1;i >= 0; --i){
        ll mx = 0;
        for(int j = 1;j * j <= a[i]; ++j){
            if(a[i] % j == 0){
                if(j != 1)mx = max(ans[j],mx);
                mx = max(ans[a[i] / j],mx);
            }
        }
        for(int j = 1;j * j <= a[i]; ++j){
            if(a[i] % j == 0){
                if(j != 1)ans[j] = max(ans[j],mx + 1);
                ans[a[i] / j] = max(ans[a[i] / j],mx + 1);
            }
        }
    }
    ll mx = 0;
    for(int i = 2;i < N; ++i){
        mx = max(mx,ans[i]);
    }
    cout << mx;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp makepair
#define deb(x) cout<<x<<"\n";
#define deB(x,y) cout<<x<<" "<<y<<"\n";
#define Deb(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define YES cout<<"YES\n";
#define Yes cout<<"Yes\n";
#define NO cout<<"NO\n";
#define No cout<<"No\n";
#define all(v) (v).begin(),(v).end()
#define N 100009
ll a[N],dp[N];
int main()
{
  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  ll i=2,j;
  while(i<=N)
  {
    if(a[i]==0)
    {
      j=i;
      while(j<=N)
      {
        a[j]=i;
        j+=i;
      }
    }
    i++;
  }
  ll n,d,mx,ans=0;
  cin>>n;
  while(n--)
  {
    cin>>d;
    vector<ll> v;
    while(d>1)
    {
      v.pb(a[d]);
      mx=a[d];
      while(d%mx==0)
        d/=mx;
    }
    mx=0;
    for(auto x:v)
      mx=max(mx,dp[x]);
    mx++;
    ans=max(ans,mx);
    for(auto x:v)
      dp[x]=max(dp[x],mx);
  }
  deb(ans)
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp makepair
#define deb(x) cout<<x<<"\n";
#define deB(x,y) cout<<x<<" "<<y<<"\n";
#define Deb(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define YES cout<<"YES\n";
#define Yes cout<<"Yes\n";
#define NO cout<<"NO\n";
#define No cout<<"No\n";
#define all(v) (v).begin(),(v).end()
int main()
{
  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  ll n,d;
  set<pair<ll,ll>> s;
  cin>>n;
  while(n--)
  {
    cin>>d;
    auto it=s.rbegin();
    while(it!=s.rend())
    {
      if(__gcd(d,(*it).ss)>1)
      {
        s.insert({(*it).ff+1,d});
        break;
      }
      it++;
    }
    if(it==s.rend())
      s.insert({1,d});
  }
  deb((*s.rbegin()).ff)
}


#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
const int N=1e5+4;
int dp[N],a[N];
vector<int> prime(N);
//dp[i] length of longest sequence ending in prime i's multiple
//prime[i] is smallest prime that divides i
int32_t main()
{
	int n;
	cin>>n;

	prime[1]=1;
	for(int i=2;i<N;i++)
	{
		if(prime[i])continue;
		for(int j=i*i;j<N;j+=i)prime[j]=i;
	}

	for(int i=1;i<N;i++)if(!prime[i])prime[i]=i;

	for(int i=1;i<=n;i++)cin>>a[i];
	if(n==1){puts("1");return 0;}
	sort(a+1,a+n+1);

	for(int i=1;i<=n;i++)
	{
		int x=a[i];
		if(x==1){dp[x]=1;continue;}
		int tx=x;
		int j=prime[tx];
		while(tx>1)
		{
			dp[x]=max(dp[x],1+dp[j]);
			while(tx%j==0){tx/=j;}
			j=prime[tx];
			if(j==1)break;
		}
		tx=x;
		j=prime[tx];
		while(tx>1)
		{
			dp[j]=dp[x];
			while(tx%j==0)tx/=j;
			j=prime[tx];
			if(j==1)break;
		}
	}
	int ans=*max_element(dp,dp+N);
	cout<<ans<<"\n";

	//for(int i=1;i<=20;i++)cout<<prime[i]<<" ";cout<<"\n";

}


#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
const int N=1e5+4;
int dp[N],a[N];
vector<bool> prime(N,1);
vector<int> p;
//dp[i] length of longest sequence ending in prime i's multiple
int32_t main()
{
	int n;
	cin>>n;

	prime[1]=prime[0]=0;
	for(int i=2;i<N;i++)
	{
		if(!prime[i])continue;
		for(int j=i*i;j<N;j+=i)prime[j]=0;
	}

	for(int i=1;i<N;i++)if(prime[i])p.push_back(i);

	for(int i=1;i<=n;i++)cin>>a[i];
	if(n==1){puts("1");return 0;}
	sort(a+1,a+n+1);

	for(int i=1;i<=n;i++)
	{
		int x=a[i];
		for(int j:p)
		{
			if(j>x)break;
			if(x%j==0)
			dp[x]=max(dp[x],1+dp[j]);
		}
		for(int j:p)
		{
			if(j>x)break;
			if(x%j==0)dp[j]=dp[x];
		}
	}
	int ans=*max_element(dp,dp+N);
	cout<<ans<<"\n";

}


#include <bits/stdc++.h>
#define pb push_back
#define sc second
#define fr first
#define mk make_pair
#define ll long long
#define ii pair<int,int>
#define mp make_pair
typedef long long intt;
using namespace std;
int a[100003];
int c[100003];
vector <vector <int> > op(100005);
int mod=1e9+7;
int n,h;
int dp[100005];
int rec(int num)
{

    if(num>1e5)
      return 0;

  int &ret=dp[num];
  if(ret!=-1)
    return ret;
    int i;
    if(c[num])
    {

    for(i=0;i<op[num].size();i++)
    {
        int cc=op[num][i];
        cc=num/op[num][i];
        int f=cc+1;
        while(op[num][i]*f<1e5)
        {
            if(c[op[num][i]*f])
            ret=max(ret,rec(op[num][i]*f)+1);
            f++;
        }
        ret=max(ret,rec(op[num][i]*f)+1);
    }
    }
    else
    {
        ret=max(ret,rec(num+1));
    }

    return ret;
}
int main()
{

ios::sync_with_stdio(false);
cin.tie();
cout.tie();
cin>>n;
intt j;
intt i;
for(i=1;i<=n;i++)
{
    int x;
    cin>>x;
    c[x]=1;
}
for(i=2;i<=100000;i++)
{
    if(!a[i])
    {
        for(j=i;j<=100000;j+=i)
            {
                a[j]=1;
                op[j].pb(i);

            }
    }
}
memset(dp,-1,sizeof dp);
if(n==1)
{
    cout<<1;
    return 0;
}
cout<<rec(2);
  return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define sc second
#define fr first
#define mk make_pair
#define ll long long
#define ii pair<int,int>
#define mp make_pair
typedef long long intt;
using namespace std;
int a[100003];
int c[100003];
int b[100003];
vector <vector <int> > op(100005);
int mod=1e9+7;
int n,h;
int dp[100005];
int rec(int num)
{

    if(num>1e5)
      return 0;

  int &ret=dp[num];
  if(ret!=-1)
    return ret;
    int i;
    if(c[num])
    {

    for(i=0;i<op[num].size();i++)
    {
        int cc=op[num][i];
        cc=num/op[num][i];
        int f=cc+1;
        while(op[num][i]*f<=1e5)
        {
            if(c[op[num][i]*f])
            {

            ret=max(ret,rec(op[num][i]*f)+1);
            break;
            }
            f++;
        }
        ret=max(ret,rec(op[num][i]*f)+1);
    }

    }
    return ret;
}
int main()
{

ios::sync_with_stdio(false);
cin.tie();
cout.tie();
cin>>n;
intt j;
intt i;
for(i=1;i<=n;i++)
{
    int x;
    cin>>x;
    b[i]=x;
    c[x]=1;
}
for(i=2;i<=100000;i++)
{
    if(!a[i])
    {
        for(j=i;j<=100000;j+=i)
            {
                a[j]=1;
                op[j].pb(i);

            }
    }
}
memset(dp,-1,sizeof dp);
if(n==1)
{
    cout<<1;
    return 0;
}
int res=0;
for(i=0;i<n;i++)
{
    if(b[i]!=1)
    res=max(res,rec(b[i]));
}
cout<<res;
  return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define sc second
#define fr first
#define mk make_pair
#define ll long long
#define ii pair<int,int>
#define mp make_pair
typedef long long intt;
using namespace std;
map<pair<int,int>,int > dp;
int a[100003];
int mod=1e9+7;
int n,h;
int rec(int i,int last)
{
    if(i>=n)
     return 0;
    int &ret=dp[mk(i,last)];
    if((ret)!=0)
    {
        return ret;
    }
    ret=0;
    ret=max(ret,rec(i+1,last));
    if(__gcd(a[i],last)>1)
    {
        ret=max(ret,rec(i+1,a[i])+1);
    }
    return ret;

}
int main()
{

ios::sync_with_stdio(false);
cin.tie();
cout.tie();
cin>>n;
int i;
for(i=0;i<n;i++)
    cin>>a[i];
cout<<rec(0,0);

  return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define sc second
#define fr first
#define mk make_pair
#define ll long long
#define ii pair<int,int>
#define mp make_pair
typedef long long intt;
using namespace std;
int a[100003];
int c[100003];
int b[100003];
vector <vector <int> > op(100005);
int mod=1e9+7;
int n,h;
int dp[100005];
int rec(int num)
{

    if(num>1e5)
      return 0;

  int &ret=dp[num];
  if(ret!=-1)
    return ret;
    int i;
    if(c[num])
    {

    for(i=0;i<op[num].size();i++)
    {
        int cc=op[num][i];
        cc=num/op[num][i];
        int f=cc+1;
        while(op[num][i]*f<=1e5)
        {
            if(c[op[num][i]*f])
            ret=max(ret,rec(op[num][i]*f)+1);
            f++;
        }
        ret=max(ret,rec(op[num][i]*f)+1);
    }

    }
    return ret;
}
int main()
{

ios::sync_with_stdio(false);
cin.tie();
cout.tie();
cin>>n;
intt j;
intt i;
for(i=1;i<=n;i++)
{
    int x;
    cin>>x;
    b[i]=x;
    c[x]=1;
}
for(i=2;i<=100000;i++)
{
    if(!a[i])
    {
        for(j=i;j<=100000;j+=i)
            {
                a[j]=1;
                op[j].pb(i);

            }
    }
}
memset(dp,-1,sizeof dp);
if(n==1)
{
    cout<<1;
    return 0;
}
int res=0;
for(i=0;i<n;i++)
{
    if(b[i]!=1)
    res=max(res,rec(b[i]));
}
cout<<res;
  return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define sc second
#define fr first
#define mk make_pair
#define ll long long
#define ii pair<int,int>
#define mp make_pair
typedef long long intt;
using namespace std;
int a[100003];
int c[100003];
vector <vector <int> > op(100005);
int mod=1e9+7;
int n,h;
int dp[100005];
int rec(int num)
{

    if(num>1e5)
      return 0;

  int &ret=dp[num];
  if(ret!=-1)
    return ret;
    int i;
    if(c[num])
    {

    for(i=0;i<op[num].size();i++)
    {
        int cc=op[num][i];
        cc=num/op[num][i];
        int f=cc+1;
        while(op[num][i]*f<=1e5)
        {
            if(c[op[num][i]*f])
            ret=max(ret,rec(op[num][i]*f)+1);
            f++;
        }
        ret=max(ret,rec(op[num][i]*f)+1);
    }
    }
    else
    {
        ret=max(ret,rec(num+1));
    }

    return ret;
}
int main()
{

ios::sync_with_stdio(false);
cin.tie();
cout.tie();
cin>>n;
intt j;
intt i;
for(i=1;i<=n;i++)
{
    int x;
    cin>>x;
    c[x]=1;
}
for(i=2;i<=100000;i++)
{
    if(!a[i])
    {
        for(j=i;j<=100000;j+=i)
            {
                a[j]=1;
                op[j].pb(i);

            }
    }
}
memset(dp,-1,sizeof dp);
if(n==1)
{
    cout<<1;
    return 0;
}
cout<<rec(2);
  return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define sc second
#define fr first
#define mk make_pair
#define ll long long
#define ii pair<int,int>
#define mp make_pair
typedef long long intt;
using namespace std;
int a[100003];
int c[100003];
int b[100003];
vector <vector <int> > op(100005);
int mod=1e9+7;
int n,h;
int dp[100005];
int rec(int num)
{

    if(num>1e5)
      return 0;

  int &ret=dp[num];
  if(ret!=-1)
    return ret;
    int i;
    if(c[num])
    {

    for(i=0;i<op[num].size();i++)
    {
        int cc=op[num][i];
        cc=num/op[num][i];
        int f=cc+1;
        while(op[num][i]*f<=1e5)
        {
            if(c[op[num][i]*f])
            ret=max(ret,rec(op[num][i]*f)+1);
            f++;
        }
        ret=max(ret,rec(op[num][i]*f)+1);
    }
    }
    else
    {
        ret=max(ret,rec(num+1));
    }

    return ret;
}
int main()
{

ios::sync_with_stdio(false);
cin.tie();
cout.tie();
cin>>n;
intt j;
intt i;
for(i=1;i<=n;i++)
{
    int x;
    cin>>x;
    b[i]=x;
    c[x]=1;
}
for(i=2;i<=100000;i++)
{
    if(!a[i])
    {
        for(j=i;j<=100000;j+=i)
            {
                a[j]=1;
                op[j].pb(i);

            }
    }
}
memset(dp,-1,sizeof dp);
if(n==1)
{
    cout<<1;
    return 0;
}
int res=0;
for(i=0;i<n;i++)
{
    if(b[i]!=1)
    res=max(res,rec(b[i]));
}
cout<<res;
  return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define sc second
#define fr first
#define mk make_pair
#define ll long long
#define ii pair<int,int>
#define mp make_pair
typedef long long intt;
using namespace std;
map<pair<int,int>,int > dp;
int a[100003];
int mod=1e9+7;
int n,h;
int rec(int i,int last)
{
    if(i>=n)
     return 0;
    int &ret=dp[mk(i,last)];
    if((ret)!=0)
    {
        return ret;
    }
    ret=0;
    ret=max(ret,rec(i+1,last));
    if(__gcd(a[i],last)>1)
    {
        ret=max(ret,rec(i+1,a[i])+1);
    }
    return ret;

}
int main()
{

ios::sync_with_stdio(false);
cin.tie();
cout.tie();
cin>>n;

int i;
for(i=0;i<n;i++)
    cin>>a[i];
intt res=rec(0,0);
cout<<max(res,1ll);

  return 0;
}


#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define popb pop_back()
#define ll long long
#define sz size()
#define all(x) x.begin(), x.end()
#define forn(x) for(ll i=1;i<=x;i++)
#define sforn(x, y) for(ll i=1;i<=x;i++)for(ll j=1;j<=y;j++)
#define pii pair<ll, ll>
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

/*
    LOL KEK CHEBUREK

    PIHALITI

 */

ll arr[200100];
ll dp[200100];
int main(){ speed;
    ll n;
    cin >> n;
    for(ll i=1;i<=n;i++) cin >> arr[i];
    for(ll i=1;i<=n;i++){
        ll cnt = 2;
        ll ma = 0;
        for(ll j = 2; j*j <= arr[i]; j++){
            if(arr[i] % j == 0)ma = max(ma, dp[j]), ma = max(ma, dp[arr[i] / j]);
        }
        for(ll j = 2; j*j <= arr[i]; j++){
            if(arr[i] % j == 0) dp[j] = ma + 1, dp[arr[i] / j] = ma+1;
        }
        dp[arr[i]] = ma + 1;
    }
    ll ans = 0;
    for(ll i=0;i<=100000;i++){
        ans = max(ans, dp[i]);
    }
    cout << ans << endl;
    return 0;
}


#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define popb pop_back()
#define ll long long
#define sz size()
#define all(x) x.begin(), x.end()
#define forn(x) for(ll i=1;i<=x;i++)
#define sforn(x, y) for(ll i=1;i<=x;i++)for(ll j=1;j<=y;j++)
#define pii pair<ll, ll>
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

/*
    LOL KEK CHEBUREK

    PIHALITI

 */

ll arr[200100];
ll dp[200100];
int main(){ speed;
    ll n;
    cin >> n;
    for(ll i=1;i<=n;i++) cin >> arr[i];
    for(ll i=1;i<=n;i++){
        ll cnt = 2;
        ll x = arr[i];
        ll ma = 0;
        while(arr[i] > 1){
            if(arr[i] % cnt == 0) {
                ++dp[cnt];
                ma = max(ma, dp[cnt]);
            }
            while(arr[i] % cnt == 0){
                arr[i] /= cnt;
            }
            ++ cnt;
        }
        cnt = 2;
        while(x > 1){
            if(x % cnt == 0) dp[cnt] = ma;
            while(x % cnt == 0) x/=cnt;
            ++cnt;
        }
    }
    ll ans = 0, num;
    for(ll i=0;i<=100000;i++){
        if(ans < dp[i]){
            ans = dp[i];
            num = i;
        }
    }
    cout << ans << endl;
    return 0;
}


// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define vi vector<ll>
#define vb vector<bool>
#define pii pair<ll,ll>
#define mod 1000000007
#define pll pair<ll,ll>
#define rep(i,n) for(ll i=0;i<n;i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per1(i,n) for(ll i=n;i>0;i--)
#define prll(a,n) for(ll i=0;i<n;i++){ cout<<a[i]<<" "; }
#define ain(a) for(auto &i:a) cin>>i
#define mms(a) memset(a,0,sizeof(a))
#define all(a) a.begin(),a.end()
// cout << fixed << setprecision(0) << pi <<" "<<npi<<endl;

ll max_ll(ll a,ll b,ll c){
	return max(a,max(b,c));
}

ll min_ll(ll a,ll b,ll c){
	return min(a,min(b,c));
}

bool sortBySec(pair<ll,ll> a,pair<ll,ll> b){
    if(a.second==b.second)
		return a.first<b.first;
    return (a.second < b.second);
}

long long binexpmod(long long a, long long b){
    long long res =1;
    while(b>0){
        if(b&1){
            res = res * a % mod;
        }
        a = a * a % mod;
        b>>=1;
    }
    return(res);
}

ll lcm(ll a,ll b){
	ll x=__gcd(a,b);
	a/=x;
	b/=x;
	ll sum=a*b*x;
	return sum;
}
void solve(){

    const int mnx = 100005;
    vi dp(mnx,0);
    vi div[mnx];
    for(ll i=2 ; i<mnx ; i++){
        for(ll j=i; j<mnx ; j+=i){
            div[j].push_back(i);
        }
    }

    ll n,res=0;
	cin>>n;
    rep(i,n){
        ll t;
        cin>>t;
        if(n==1){ cout<<1<<endl ; return;}
        ll mx=0;
        for(auto &p:div[t]){
            mx = max(mx, dp[p]);
        }
        for(auto &p:div[t]){
            dp[p] = mx+1;
        }
    }
    for(ll i=2;i<mnx-4;i++){
        res = max(res, dp[i]);
    }
	cout<<res<<endl;
	return;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
	// cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}


// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define vi vector<ll>
#define vb vector<bool>
#define pii pair<ll,ll>
#define mod 1000000007
#define pll pair<ll,ll>
#define rep(i,n) for(ll i=0;i<n;i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per1(i,n) for(ll i=n;i>0;i--)
#define prll(a,n) for(ll i=0;i<n;i++){ cout<<a[i]<<" "; }
#define ain(a) for(auto &i:a) cin>>i
#define mms(a) memset(a,0,sizeof(a))
#define all(a) a.begin(),a.end()
// cout << fixed << setprecision(0) << pi <<" "<<npi<<endl;

// ll max_ll(ll a,ll b,ll c){
// 	return max(a,max(b,c));
// }

// ll min_ll(ll a,ll b,ll c){
// 	return min(a,min(b,c));
// }

// bool sortBySec(pair<ll,ll> a,pair<ll,ll> b){
//     if(a.second==b.second)
// 		return a.first<b.first;
//     return (a.second < b.second);
// }

// long long binexpmod(long long a, long long b){
//     long long res =1;
//     while(b>0){
//         if(b&1){
//             res = res * a % mod;
//         }
//         a = a * a % mod;
//         b>>=1;
//     }
//     return(res);
// }

// ll lcm(ll a,ll b){
// 	ll x=__gcd(a,b);
// 	a/=x;
// 	b/=x;
// 	ll sum=a*b*x;
// 	return sum;
// }

bool prime[100005];
vi primes;
void sieve(ll n)
{
    memset(prime, true, sizeof(prime));
    for (ll p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (ll i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for(ll i=2;i<=n;i++){
        if(prime[i]) primes.push_back(i);
    }
}
void solve(){
    ll n,res=0;
	cin>>n;
    vi a(n);
    ain(a);
    vi fac[n];
    rep(p,primes.size()){
        ll par=0;
        bool f=true;
        rep(i,n){
            if(a[i]%primes[p] ==0){
                // v[p].push_back(par);
                if(f){
                    fac[i].push_back(i);
                    par = i;
                    f = false;
                }
                else{
                    fac[i].push_back(par);
                    par=i;
                }
            }
        }
    }
    vi dp(n+1,1);
    for(ll i=0; i<n; ++i){
        for(auto j:fac[i]){
            if(j==i) continue;
            dp[i] = max(dp[i] , dp[j]+1);
        }
    }
	cout<<dp[n-1]<<endl;
	return;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
	// cin>>t;
    sieve(sqrt(100000));
	while(t--)
	{
		solve();
	}
	return 0;
}


// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define vi vector<ll>
#define vb vector<bool>
#define pii pair<ll,ll>
#define mod 1000000007
#define pll pair<ll,ll>
#define rep(i,n) for(ll i=0;i<n;i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per1(i,n) for(ll i=n;i>0;i--)
#define prll(a,n) for(ll i=0;i<n;i++){ cout<<a[i]<<" "; }
#define ain(a) for(auto &i:a) cin>>i
#define mms(a) memset(a,0,sizeof(a))
#define all(a) a.begin(),a.end()
// cout << fixed << setprecision(0) << pi <<" "<<npi<<endl;

// ll max_ll(ll a,ll b,ll c){
// 	return max(a,max(b,c));
// }

// ll min_ll(ll a,ll b,ll c){
// 	return min(a,min(b,c));
// }

// bool sortBySec(pair<ll,ll> a,pair<ll,ll> b){
//     if(a.second==b.second)
// 		return a.first<b.first;
//     return (a.second < b.second);
// }

// long long binexpmod(long long a, long long b){
//     long long res =1;
//     while(b>0){
//         if(b&1){
//             res = res * a % mod;
//         }
//         a = a * a % mod;
//         b>>=1;
//     }
//     return(res);
// }

// ll lcm(ll a,ll b){
// 	ll x=__gcd(a,b);
// 	a/=x;
// 	b/=x;
// 	ll sum=a*b*x;
// 	return sum;
// }

bool prime[100005];
vi primes;
void sieve(ll n)
{
    memset(prime, true, sizeof(prime));
    for (ll p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (ll i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for(ll i=2;i<=n;i++){
        if(prime[i]) primes.push_back(i);
    }
}
void solve(){
    ll n,res=0;
	cin>>n;
    vi a(n);
    ain(a);
    vi fac[n];
    rep(p,primes.size()){
        ll par=0;
        bool f=true;
        rep(i,n){
            if(a[i]%primes[p] ==0){
                // v[p].push_back(par);
                if(f){
                    fac[i].push_back(i);
                    par = i;
                    f = false;
                }
                else{
                    fac[i].push_back(par);
                    par=i;
                }
            }
        }
    }
    vi dp(n,1);
    for(ll i=0; i<n; ++i){
        for(auto j:fac[i]){
            if(j==i) continue;
            dp[i] = max(dp[i] , dp[j]+1);
        }
    }
    rep(i,n){
        res = max(res,dp[i]);
    }
	cout<<res<<endl;
	return;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
	// cin>>t;
    sieve(100000);
	while(t--)
	{
		solve();
	}
	return 0;
}


// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define vi vector<ll>
#define vb vector<bool>
#define pii pair<ll,ll>
#define mod 1000000007
#define pll pair<ll,ll>
#define rep(i,n) for(ll i=0;i<n;i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per1(i,n) for(ll i=n;i>0;i--)
#define prll(a,n) for(ll i=0;i<n;i++){ cout<<a[i]<<" "; }
#define ain(a) for(auto &i:a) cin>>i
#define mms(a) memset(a,0,sizeof(a))
#define all(a) a.begin(),a.end()
// cout << fixed << setprecision(0) << pi <<" "<<npi<<endl;

ll max_ll(ll a,ll b,ll c){
	return max(a,max(b,c));
}

ll min_ll(ll a,ll b,ll c){
	return min(a,min(b,c));
}

bool sortBySec(pair<ll,ll> a,pair<ll,ll> b){
    if(a.second==b.second)
		return a.first<b.first;
    return (a.second < b.second);
}

long long binexpmod(long long a, long long b){
    long long res =1;
    while(b>0){
        if(b&1){
            res = res * a % mod;
        }
        a = a * a % mod;
        b>>=1;
    }
    return(res);
}

ll lcm(ll a,ll b){
	ll x=__gcd(a,b);
	a/=x;
	b/=x;
	ll sum=a*b*x;
	return sum;
}
void solve(){

    const int mnx = 100005;
    vi dp(mnx,0);
    vi div[mnx];
    for(ll i=2 ; i*i<mnx ; i++){
        for(ll j=i; j<mnx ; j+=i){
            div[j].push_back(i);
        }
    }

    ll n,res=0;
	cin>>n;
    rep(i,n){
        ll t;
        cin>>t;
        if(n==1){ cout<<1<<endl ; continue;}
        ll mx=0;
        for(auto &p:div[t]){
            mx = max(mx, dp[p]);
        }
        for(auto &p:div[t]){
            dp[p] = mx+1;
        }
    }
    for(ll i=2;i<mnx-4;i++){
        res = max(res, dp[i]);
    }
	cout<<res<<endl;
	return;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
	// cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}


// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define vi vector<ll>
#define vb vector<bool>
#define pii pair<ll,ll>
#define mod 1000000007
#define pll pair<ll,ll>
#define rep(i,n) for(ll i=0;i<n;i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per1(i,n) for(ll i=n;i>0;i--)
#define prll(a,n) for(ll i=0;i<n;i++){ cout<<a[i]<<" "; }
#define ain(a) for(auto &i:a) cin>>i
#define mms(a) memset(a,0,sizeof(a))
#define all(a) a.begin(),a.end()
// cout << fixed << setprecision(0) << pi <<" "<<npi<<endl;

ll max_ll(ll a,ll b,ll c){
	return max(a,max(b,c));
}

ll min_ll(ll a,ll b,ll c){
	return min(a,min(b,c));
}

bool sortBySec(pair<ll,ll> a,pair<ll,ll> b){
    if(a.second==b.second)
		return a.first<b.first;
    return (a.second < b.second);
}

long long binexpmod(long long a, long long b){
    long long res =1;
    while(b>0){
        if(b&1){
            res = res * a % mod;
        }
        a = a * a % mod;
        b>>=1;
    }
    return(res);
}

ll lcm(ll a,ll b){
	ll x=__gcd(a,b);
	a/=x;
	b/=x;
	ll sum=a*b*x;
	return sum;
}
void solve(){

    const int mnx = 100005;
    vi dp(mnx,0);
    vi div[mnx];
    for(ll i=2 ; i*i<mnx ; i++){
        for(ll j=i; j<mnx ; j+=i){
            div[j].push_back(i);
        }
    }

    ll n,res=0;
	cin>>n;
    rep(i,n){
        ll t;
        cin>>t;
        if(n==1){ cout<<1<<endl ; return;}
        ll mx=0;
        for(auto &p:div[t]){
            mx = max(mx, dp[p]);
        }
        for(auto &p:div[t]){
            dp[p] = mx+1;
        }
    }
    for(ll i=2;i<mnx-4;i++){
        res = max(res, dp[i]);
    }
	cout<<res<<endl;
	return;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
	// cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}


// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define vi vector<ll>
#define vb vector<bool>
#define pii pair<ll,ll>
#define mod 1000000007
#define pll pair<ll,ll>
#define rep(i,n) for(ll i=0;i<n;i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per1(i,n) for(ll i=n;i>0;i--)
#define prll(a,n) for(ll i=0;i<n;i++){ cout<<a[i]<<" "; }
#define ain(a) for(auto &i:a) cin>>i
#define mms(a) memset(a,0,sizeof(a))
#define all(a) a.begin(),a.end()
// cout << fixed << setprecision(0) << pi <<" "<<npi<<endl;

// ll max_ll(ll a,ll b,ll c){
// 	return max(a,max(b,c));
// }

// ll min_ll(ll a,ll b,ll c){
// 	return min(a,min(b,c));
// }

// bool sortBySec(pair<ll,ll> a,pair<ll,ll> b){
//     if(a.second==b.second)
// 		return a.first<b.first;
//     return (a.second < b.second);
// }

// long long binexpmod(long long a, long long b){
//     long long res =1;
//     while(b>0){
//         if(b&1){
//             res = res * a % mod;
//         }
//         a = a * a % mod;
//         b>>=1;
//     }
//     return(res);
// }

// ll lcm(ll a,ll b){
// 	ll x=__gcd(a,b);
// 	a/=x;
// 	b/=x;
// 	ll sum=a*b*x;
// 	return sum;
// }

bool prime[100005];
vi primes;
void sieve(ll n)
{
    memset(prime, true, sizeof(prime));
    for (ll p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (ll i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for(ll i=2;i<=n;i++){
        if(prime[i]) primes.push_back(i);
    }
}
void solve(){
    ll n,res=0;
	cin>>n;
    vi a(n);
    ain(a);
    vi fac[n];
    vi piri(primes.size(),-1);
    // rep(p,primes.size()){
    //     ll par=0;
    //     bool f=true;
    //     rep(i,n){
    //         if(a[i]%primes[p] ==0){
    //             // v[p].push_back(par);
    //             if(f){
    //                 fac[i].push_back(i);
    //                 par = i;
    //                 f = false;
    //             }
    //             else{
    //                 fac[i].push_back(par);
    //                 par=i;
    //             }
    //         }
    //     }
    // }

    rep(i,n){
        if(a[i]==1) continue;
        ll s = sqrt(a[i]);
        for(ll p = 0 ; p<primes.size() ; ++p){

            if(primes[p]>a[i]){
                break;
            }
            if(a[i]%primes[p] ==0){
                if(piri[p]==-1){
                    fac[i].push_back(i);
                    piri[p] = i;
                }
                else{
                    fac[i].push_back(piri[p]);
                    piri[p] = i;
                }
            }
        }
        // for (auto x:fac[i]) cout<<"fac["<<i<<"] = "<<x<<endl;
    }
    vi dp(n,1);
    for(ll i=0; i<n; ++i){
        for(auto j:fac[i]){
            if(j==i) continue;
            dp[i] = max(dp[i] , dp[j]+1);
        }
    }
    rep(i,n){
        res = max(res,dp[i]);
    }
	cout<<res<<endl;
	return;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
	// cin>>t;
    sieve(100000);
	while(t--)
	{
		solve();
	}
	return 0;
}