#include <bits/stdc++.h>
using namespace std;
template <class T, class first>
inline bool getbit(T a, first i) {
  T t = 1;
  return ((a & (t << i)) > 0);
}
template <class T, class first>
inline T setbit(T a, first i) {
  T t = 1;
  return (a | (t << i));
}
template <class T, class first>
inline T resetbit(T a, first i) {
  T t = 1;
  return (a & (~(t << i)));
}
template <class T, class first>
inline T togglebit(T a, first i) {
  T t = 1;
  return (a ^ (t << i));
}
template <typename T>
T POW(T B, T P) {
  if (P == 0) return 1;
  if (P & 1)
    return B * POW(B, P - 1);
  else
    return (POW(B, P / 2) * POW(B, P / 2));
}
template <typename T>
T BIGMOD(T b, T p, T m) {
  if (p == 0)
    return 1;
  else if (!(p & 1))
    return (Bigmod(b, p / 2, m) * Bigmod(b, p / 2, m)) % m;
  else
    return ((b % m) * Bigmod(b, p - 1, m)) % m;
}
template <typename T>
T Bigmod(T base, T power, T mod) {
  T ret = 1;
  while (power) {
    if (power & 1) ret = (ret * base) % mod;
    base = (base * base) % mod;
    power >>= 1;
  }
  return ret;
}
template <typename T>
T ModInverse(T number, T mod) {
  return Bigmod(number, mod - 2, mod);
}
template <typename T>
T GCD(T a, T b) {
  if (a < 0) return gcd(-a, b);
  if (b < 0) return gcd(a, -b);
  return (b == 0) ? a : gcd(b, a % b);
}
template <typename T>
T LCM(T a, T b) {
  if (a < 0) return lcm(-a, b);
  if (b < 0) return lcm(a, -b);
  return a * (b / gcd(a, b));
}
template <typename T>
T EUCLIDE(T a, T b, T &x, T &y) {
  if (a < 0) {
    T d = euclide(-a, b, x, y);
    x = -x;
    return d;
  }
  if (b < 0) {
    T d = euclide(a, -b, x, y);
    y = -y;
    return d;
  }
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  } else {
    T d = euclide(b, a % b, x, y);
    T t = x;
    x = y;
    y = t - (a / b) * y;
    return d;
  }
}
template <typename T>
T ABS(T a) {
  if (a < 0)
    return -a;
  else
    return a;
}
double DEG(double x) { return (180.0 * x) / ((2.0 * acos(0.0))); }
double RAD(double x) { return (x * (double)(2.0 * acos(0.0))) / (180.0); }
template <typename T>
T DIS(T x1, T y1, T x2, T y2) {
  return sqrt((double)((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)));
}
template <typename T>
T ANGLE(T x1, T y1, T x2, T y2) {
  return atan(double(y1 - y2) / double(x1 - x2));
}
template <typename T>
long long isLeft(T a, T b, T c) {
  return (c.x - a.x) * (b.y - a.y) - (b.x - a.x) * (c.y - a.y);
}
void P_ARR(int *ar, int a, int b) {
  if (a > b) swap(a, b);
  if (a <= b) cout << ar[a];
  for (int i = a + 1; i <= b; i++) cout << " " << ar[i];
  cout << endl;
}
int pos[100007];
vector<int> adj[100007];
int ar[100007];
int dp[100007];
int pre[100007];
bool is[100007];
int prime[100007];
int psz;
void sieve() {
  prime[psz++] = 2;
  for (int i = 3; i < 100007; i += 2) {
    if (!is[i]) {
      prime[psz++] = i;
      for (int j = (i + i + i); j < 100007; j += (i + i)) {
        is[j] = 1;
      }
    }
  }
}
int call(int pos) {
  int &ret = dp[pos];
  if (ret != -1) return ret;
  ret = 1;
  for (int i = 0; i < (int)adj[pos].size(); i++) {
    int v = adj[pos][i];
    ret = max(call(v) + 1, ret);
  }
  return ret;
}
void make_edge(int n, int u) {
  int sr = sqrt(n);
  for (int i = 0; i < psz && prime[i] <= sr; i++) {
    if (n % prime[i] == 0) {
      if (pos[prime[i]]) adj[u].push_back(pos[prime[i]]);
      while (n % prime[i] == 0) n /= prime[i];
      sr = sqrt(n);
    }
  }
  if (n != 1) {
    if (pos[n]) adj[u].push_back(pos[n]);
  }
}
void make_seat(int n, int u) {
  int sr = sqrt(n);
  for (int i = 0; i < psz && prime[i] <= sr; i++) {
    if (n % prime[i] == 0) {
      pos[prime[i]] = u;
      while (n % prime[i] == 0) n /= prime[i];
      sr = sqrt(n);
    }
  }
  if (n != 1) {
    pos[n] = u;
  }
}
int main() {
  sieve();
  int(n);
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int(a);
    scanf("%d", &a);
    make_edge(a, i);
    make_seat(a, i);
  }
  memset(dp, -1, sizeof dp);
  int res = -1;
  for (int i = 1; i <= n; i++) res = max(res, call(i));
  cout << res << endl;
  return 0;
}

### Prompt

Please create a solution in cpp 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;
template <class T, class first>
inline bool getbit(T a, first i) {
  T t = 1;
  return ((a & (t << i)) > 0);
}
template <class T, class first>
inline T setbit(T a, first i) {
  T t = 1;
  return (a | (t << i));
}
template <class T, class first>
inline T resetbit(T a, first i) {
  T t = 1;
  return (a & (~(t << i)));
}
template <class T, class first>
inline T togglebit(T a, first i) {
  T t = 1;
  return (a ^ (t << i));
}
template <typename T>
T POW(T B, T P) {
  if (P == 0) return 1;
  if (P & 1)
    return B * POW(B, P - 1);
  else
    return (POW(B, P / 2) * POW(B, P / 2));
}
template <typename T>
T BIGMOD(T b, T p, T m) {
  if (p == 0)
    return 1;
  else if (!(p & 1))
    return (Bigmod(b, p / 2, m) * Bigmod(b, p / 2, m)) % m;
  else
    return ((b % m) * Bigmod(b, p - 1, m)) % m;
}
template <typename T>
T Bigmod(T base, T power, T mod) {
  T ret = 1;
  while (power) {
    if (power & 1) ret = (ret * base) % mod;
    base = (base * base) % mod;
    power >>= 1;
  }
  return ret;
}
template <typename T>
T ModInverse(T number, T mod) {
  return Bigmod(number, mod - 2, mod);
}
template <typename T>
T GCD(T a, T b) {
  if (a < 0) return gcd(-a, b);
  if (b < 0) return gcd(a, -b);
  return (b == 0) ? a : gcd(b, a % b);
}
template <typename T>
T LCM(T a, T b) {
  if (a < 0) return lcm(-a, b);
  if (b < 0) return lcm(a, -b);
  return a * (b / gcd(a, b));
}
template <typename T>
T EUCLIDE(T a, T b, T &x, T &y) {
  if (a < 0) {
    T d = euclide(-a, b, x, y);
    x = -x;
    return d;
  }
  if (b < 0) {
    T d = euclide(a, -b, x, y);
    y = -y;
    return d;
  }
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  } else {
    T d = euclide(b, a % b, x, y);
    T t = x;
    x = y;
    y = t - (a / b) * y;
    return d;
  }
}
template <typename T>
T ABS(T a) {
  if (a < 0)
    return -a;
  else
    return a;
}
double DEG(double x) { return (180.0 * x) / ((2.0 * acos(0.0))); }
double RAD(double x) { return (x * (double)(2.0 * acos(0.0))) / (180.0); }
template <typename T>
T DIS(T x1, T y1, T x2, T y2) {
  return sqrt((double)((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)));
}
template <typename T>
T ANGLE(T x1, T y1, T x2, T y2) {
  return atan(double(y1 - y2) / double(x1 - x2));
}
template <typename T>
long long isLeft(T a, T b, T c) {
  return (c.x - a.x) * (b.y - a.y) - (b.x - a.x) * (c.y - a.y);
}
void P_ARR(int *ar, int a, int b) {
  if (a > b) swap(a, b);
  if (a <= b) cout << ar[a];
  for (int i = a + 1; i <= b; i++) cout << " " << ar[i];
  cout << endl;
}
int pos[100007];
vector<int> adj[100007];
int ar[100007];
int dp[100007];
int pre[100007];
bool is[100007];
int prime[100007];
int psz;
void sieve() {
  prime[psz++] = 2;
  for (int i = 3; i < 100007; i += 2) {
    if (!is[i]) {
      prime[psz++] = i;
      for (int j = (i + i + i); j < 100007; j += (i + i)) {
        is[j] = 1;
      }
    }
  }
}
int call(int pos) {
  int &ret = dp[pos];
  if (ret != -1) return ret;
  ret = 1;
  for (int i = 0; i < (int)adj[pos].size(); i++) {
    int v = adj[pos][i];
    ret = max(call(v) + 1, ret);
  }
  return ret;
}
void make_edge(int n, int u) {
  int sr = sqrt(n);
  for (int i = 0; i < psz && prime[i] <= sr; i++) {
    if (n % prime[i] == 0) {
      if (pos[prime[i]]) adj[u].push_back(pos[prime[i]]);
      while (n % prime[i] == 0) n /= prime[i];
      sr = sqrt(n);
    }
  }
  if (n != 1) {
    if (pos[n]) adj[u].push_back(pos[n]);
  }
}
void make_seat(int n, int u) {
  int sr = sqrt(n);
  for (int i = 0; i < psz && prime[i] <= sr; i++) {
    if (n % prime[i] == 0) {
      pos[prime[i]] = u;
      while (n % prime[i] == 0) n /= prime[i];
      sr = sqrt(n);
    }
  }
  if (n != 1) {
    pos[n] = u;
  }
}
int main() {
  sieve();
  int(n);
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int(a);
    scanf("%d", &a);
    make_edge(a, i);
    make_seat(a, i);
  }
  memset(dp, -1, sizeof dp);
  int res = -1;
  for (int i = 1; i <= n; i++) res = max(res, call(i));
  cout << res << endl;
  return 0;
}

```