#include <bits/stdc++.h>
using namespace std;
long long int a[100000 + 1], spf[100000 + 1];
long long int const MAXN = 100001;
long long int modex(long long int x, long long int y, long long int p);
void getZarr(string str, long long int Z[]);
void sieve() {
  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;
    }
  }
}
vector<long long int> getFactorization(long long int x) {
  vector<long long int> ret;
  while (x != 1) {
    ret.push_back(spf[x]);
    x = x / spf[x];
  }
  return ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int n;
  cin >> n;
  long long int a[n];
  map<long long int, vector<long long int> > m;
  sieve();
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
    vector<long long int> v = getFactorization(a[i]);
    set<long long int> s;
    for (auto x : v) s.insert(x);
    for (auto x : s) m[a[i]].push_back(x);
  }
  if (n == 1 && a[0] == 1)
    cout << 1 << '\n';
  else {
    long long int dp1[n], dp2[100000 + 1] = {0};
    for (long long int i = 0; i < n; i++) {
      long long int maxi = -1000000000000;
      for (auto x = m[a[i]].begin(); x != m[a[i]].end(); x++) {
        maxi = max(maxi, dp2[*x]);
      }
      dp1[i] = maxi + 1;
      for (auto x = m[a[i]].begin(); x != m[a[i]].end(); x++) {
        dp2[*x] = max(dp2[*x], dp1[i]);
      }
    }
    long long int ans = -100000000000;
    for (long long int i = 0; i < n; i++) ans = max(ans, dp1[i]);
    cout << ans << '\n';
  }
}
void getZarr(string str, long long int Z[]) {
  Z[0] = 0;
  long long int n = str.length();
  long long int L, R, k;
  L = R = 0;
  for (long long int i = 1; i < n; i++) {
    if (i > R) {
      L = R = i;
      while (R < n && str[R - L] == str[R]) R++;
      Z[i] = R - L;
      R--;
    } else {
      k = i - L;
      if (Z[k] < R - i + 1)
        Z[i] = Z[k];
      else {
        L = i;
        while (R < n && str[R - L] == str[R]) R++;
        Z[i] = R - L;
        R--;
      }
    }
  }
}
long long int modex(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}

### Prompt

Your challenge is to write a CPP solution to the following problem:

Squirrel Liss is interested in sequences. She also has preferences of integers. She thinks n integers a1, a2, ..., an are good.

Now she is interested in good sequences. A sequence x1, x2, ..., xk is called good if it satisfies the following three conditions:

  * The sequence is strictly increasing, i.e. xi < xi + 1 for each i (1 ≤ i ≤ k - 1). 
  * No two adjacent elements are coprime, i.e. gcd(xi, xi + 1) > 1 for each i (1 ≤ i ≤ k - 1) (where gcd(p, q) denotes the greatest common divisor of the integers p and q). 
  * All elements of the sequence are good integers. 



Find the length of the longest good sequence.

Input

The input consists of two lines. The first line contains a single integer n (1 ≤ n ≤ 105) — the number of good integers. The second line contains a single-space separated list of good integers a1, a2, ..., an in strictly increasing order (1 ≤ ai ≤ 105; ai < ai + 1).

Output

Print a single integer — the length of the longest good sequence.

Examples

Input

5
2 3 4 6 9


Output

4


Input

9
1 2 3 5 6 7 8 9 10


Output

4

Note

In the first example, the following sequences are examples of good sequences: [2; 4; 6; 9], [2; 4; 6], [3; 9], [6]. The length of the longest good sequence is 4.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long int a[100000 + 1], spf[100000 + 1];
long long int const MAXN = 100001;
long long int modex(long long int x, long long int y, long long int p);
void getZarr(string str, long long int Z[]);
void sieve() {
  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;
    }
  }
}
vector<long long int> getFactorization(long long int x) {
  vector<long long int> ret;
  while (x != 1) {
    ret.push_back(spf[x]);
    x = x / spf[x];
  }
  return ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int n;
  cin >> n;
  long long int a[n];
  map<long long int, vector<long long int> > m;
  sieve();
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
    vector<long long int> v = getFactorization(a[i]);
    set<long long int> s;
    for (auto x : v) s.insert(x);
    for (auto x : s) m[a[i]].push_back(x);
  }
  if (n == 1 && a[0] == 1)
    cout << 1 << '\n';
  else {
    long long int dp1[n], dp2[100000 + 1] = {0};
    for (long long int i = 0; i < n; i++) {
      long long int maxi = -1000000000000;
      for (auto x = m[a[i]].begin(); x != m[a[i]].end(); x++) {
        maxi = max(maxi, dp2[*x]);
      }
      dp1[i] = maxi + 1;
      for (auto x = m[a[i]].begin(); x != m[a[i]].end(); x++) {
        dp2[*x] = max(dp2[*x], dp1[i]);
      }
    }
    long long int ans = -100000000000;
    for (long long int i = 0; i < n; i++) ans = max(ans, dp1[i]);
    cout << ans << '\n';
  }
}
void getZarr(string str, long long int Z[]) {
  Z[0] = 0;
  long long int n = str.length();
  long long int L, R, k;
  L = R = 0;
  for (long long int i = 1; i < n; i++) {
    if (i > R) {
      L = R = i;
      while (R < n && str[R - L] == str[R]) R++;
      Z[i] = R - L;
      R--;
    } else {
      k = i - L;
      if (Z[k] < R - i + 1)
        Z[i] = Z[k];
      else {
        L = i;
        while (R < n && str[R - L] == str[R]) R++;
        Z[i] = R - L;
        R--;
      }
    }
  }
}
long long int modex(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}

```