#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const long double EPS = 1e-9;
const long double PI = acos(-1);
const long long INF = 1e18;
const long long mod = 1e9 + 7;
long long factorial(long long n) {
  if (n == 0) return 1;
  long long x = 1;
  for (long long i = 1; i <= n; i++) {
    x = (x * i) % mod;
  }
  return x;
}
long long power(long long x, long long y) {
  long long res = 1;
  x = x % mod;
  while (y > 0) {
    if (y & 1) res = (res * x) % mod;
    x = (x * x) % mod;
    y = y >> 1;
  }
  return res % mod;
}
long long modInverse(long long n) { return power(n, mod - 2); }
long long nCr(long long n, long long r) {
  if (n < r) return 0;
  if (r == 0) return 1;
  return ((factorial(n) % mod) *
          (modInverse(((factorial(r) % mod) * (factorial(n - r) % mod)) % mod) %
           mod) %
          mod);
}
long long xor_1_x(long long x) {
  if (x % 4 == 0) return x;
  if (x % 4 == 1) return 1;
  if (x % 4 == 2) return x + 1;
  return 0;
}
bool prime(long long n) {
  if (n < 2) return false;
  for (long long x = 2; x * x <= n; x++) {
    if (n % x == 0) return false;
  }
  return true;
}
vector<long long> factors(long long n) {
  vector<long long> f;
  for (long x = 2; x * x <= n; x++) {
    while (n % x == 0) {
      f.push_back(x);
      n /= x;
    }
  }
  if (n > 1) f.push_back(n);
  return f;
}
vector<pair<int, int> > p[100005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int test_cases = 1, tt = 1;
  while (test_cases--) {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i <= n - 1; i++) cin >> a[i];
    int dp[n], ans = 0;
    for (int i = 0; i <= n - 1; i++) {
      dp[i] = 1;
      int t = a[i];
      vector<long long> f;
      for (long x = 2; x * x <= t; x++) {
        while (t % x == 0) {
          f.push_back(x);
          t /= x;
        }
      }
      if (t > 1) f.push_back(t);
      for (auto u : f) {
        if (!p[u].empty()) dp[i] = max(dp[p[u].back().second] + 1, dp[i]);
      }
      for (auto u : f) {
        p[u].push_back({a[i], i});
      }
      ans = max(ans, dp[i]);
    }
    cout << ans << endl;
  }
  return 0;
}

### Prompt

Your task is to create 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>
#pragma GCC optimize("Ofast")
using namespace std;
const long double EPS = 1e-9;
const long double PI = acos(-1);
const long long INF = 1e18;
const long long mod = 1e9 + 7;
long long factorial(long long n) {
  if (n == 0) return 1;
  long long x = 1;
  for (long long i = 1; i <= n; i++) {
    x = (x * i) % mod;
  }
  return x;
}
long long power(long long x, long long y) {
  long long res = 1;
  x = x % mod;
  while (y > 0) {
    if (y & 1) res = (res * x) % mod;
    x = (x * x) % mod;
    y = y >> 1;
  }
  return res % mod;
}
long long modInverse(long long n) { return power(n, mod - 2); }
long long nCr(long long n, long long r) {
  if (n < r) return 0;
  if (r == 0) return 1;
  return ((factorial(n) % mod) *
          (modInverse(((factorial(r) % mod) * (factorial(n - r) % mod)) % mod) %
           mod) %
          mod);
}
long long xor_1_x(long long x) {
  if (x % 4 == 0) return x;
  if (x % 4 == 1) return 1;
  if (x % 4 == 2) return x + 1;
  return 0;
}
bool prime(long long n) {
  if (n < 2) return false;
  for (long long x = 2; x * x <= n; x++) {
    if (n % x == 0) return false;
  }
  return true;
}
vector<long long> factors(long long n) {
  vector<long long> f;
  for (long x = 2; x * x <= n; x++) {
    while (n % x == 0) {
      f.push_back(x);
      n /= x;
    }
  }
  if (n > 1) f.push_back(n);
  return f;
}
vector<pair<int, int> > p[100005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int test_cases = 1, tt = 1;
  while (test_cases--) {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i <= n - 1; i++) cin >> a[i];
    int dp[n], ans = 0;
    for (int i = 0; i <= n - 1; i++) {
      dp[i] = 1;
      int t = a[i];
      vector<long long> f;
      for (long x = 2; x * x <= t; x++) {
        while (t % x == 0) {
          f.push_back(x);
          t /= x;
        }
      }
      if (t > 1) f.push_back(t);
      for (auto u : f) {
        if (!p[u].empty()) dp[i] = max(dp[p[u].back().second] + 1, dp[i]);
      }
      for (auto u : f) {
        p[u].push_back({a[i], i});
      }
      ans = max(ans, dp[i]);
    }
    cout << ans << endl;
  }
  return 0;
}

```