#include <bits/stdc++.h>
using namespace std;
long long dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
long long ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1},
          ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
long long gcd(long long a, long long b) {
  if (!a) return b;
  return gcd(b % a, a);
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
const long long template_array_size = 1e6 + 2047;
const long long N = 1e5 + 6;
const long long mod = 1e9 + 7;
long long mul(long long a, long long b) { return (a % mod) * (b % mod) % mod; }
long long add(long long a, long long b) { return (a + b) % mod; }
long long sub(long long a, long long b) {
  return (a % mod - b % mod + mod) % mod;
}
long long divide(long long a, long long b) {
  return a * (long long)pow(b, mod - 2) % mod;
}
struct Sieve {
  long long n;
  vector<long long> f, primes;
  Sieve(long long n = 1) : n(n), f(n + 1) {
    f[0] = f[1] = -1;
    for (long long i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (long long j = i * i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(long long x) { return f[x] == x; }
  vector<long long> factorList(long long x) {
    vector<long long> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<pair<long long, long long> > factor(long long x) {
    vector<long long> fl = factorList(x);
    if (fl.size() == 0) return vector<pair<long long, long long> >();
    vector<pair<long long, long long> > res(1, make_pair(fl[0], 0));
    for (long long p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.push_back(make_pair(p, 1));
      }
    }
    return res;
  }
};
void test_case() {
  long long n;
  cin >> n;
  set<long long> st;
  for (long long i = 0; i < (long long)(n); i++) {
    long long c;
    cin >> c;
    st.insert(c);
  }
  vector<long long> arr(st.begin(), st.end());
  n = arr.size();
  Sieve s(1e5 + 7);
  map<long long, long long> mp;
  for (long long i = 1; i <= 1e5; i++) {
    if (s.isPrime(i)) {
      mp[i] = 0;
    }
  }
  long long ans = 1;
  for (long long i = 0; i < n; i++) {
    auto fac = s.factorList(arr[i]);
    long long ma = 0;
    for (auto it : fac) {
      ma = max(ma, mp[it]);
    }
    ma++;
    for (auto it : fac) {
      mp[it] = ma;
    }
    ans = max(ans, ma);
  }
  cout << ans << "\n";
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(20);
  long long t = 1;
  while (t--) {
    test_case();
  }
}

### Prompt

Develop a solution in CPP to the problem described below:

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 dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
long long ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1},
          ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
long long gcd(long long a, long long b) {
  if (!a) return b;
  return gcd(b % a, a);
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
const long long template_array_size = 1e6 + 2047;
const long long N = 1e5 + 6;
const long long mod = 1e9 + 7;
long long mul(long long a, long long b) { return (a % mod) * (b % mod) % mod; }
long long add(long long a, long long b) { return (a + b) % mod; }
long long sub(long long a, long long b) {
  return (a % mod - b % mod + mod) % mod;
}
long long divide(long long a, long long b) {
  return a * (long long)pow(b, mod - 2) % mod;
}
struct Sieve {
  long long n;
  vector<long long> f, primes;
  Sieve(long long n = 1) : n(n), f(n + 1) {
    f[0] = f[1] = -1;
    for (long long i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (long long j = i * i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(long long x) { return f[x] == x; }
  vector<long long> factorList(long long x) {
    vector<long long> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<pair<long long, long long> > factor(long long x) {
    vector<long long> fl = factorList(x);
    if (fl.size() == 0) return vector<pair<long long, long long> >();
    vector<pair<long long, long long> > res(1, make_pair(fl[0], 0));
    for (long long p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.push_back(make_pair(p, 1));
      }
    }
    return res;
  }
};
void test_case() {
  long long n;
  cin >> n;
  set<long long> st;
  for (long long i = 0; i < (long long)(n); i++) {
    long long c;
    cin >> c;
    st.insert(c);
  }
  vector<long long> arr(st.begin(), st.end());
  n = arr.size();
  Sieve s(1e5 + 7);
  map<long long, long long> mp;
  for (long long i = 1; i <= 1e5; i++) {
    if (s.isPrime(i)) {
      mp[i] = 0;
    }
  }
  long long ans = 1;
  for (long long i = 0; i < n; i++) {
    auto fac = s.factorList(arr[i]);
    long long ma = 0;
    for (auto it : fac) {
      ma = max(ma, mp[it]);
    }
    ma++;
    for (auto it : fac) {
      mp[it] = ma;
    }
    ans = max(ans, ma);
  }
  cout << ans << "\n";
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(20);
  long long t = 1;
  while (t--) {
    test_case();
  }
}

```