#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1E9 + 5;
const long long LINF = (long long)4E18 + 5;
const long double PI = acos(-1.0);
const long double E = 2.718281828459045L;
const double EPS = 1.0e-9;
void debugarr(int* arr, int n) {
  cout << "[";
  for (int i = 0; i < n; i++) cout << arr[i] << " ";
  cout << "]" << endl;
}
template <typename T>
T gcd(T a, T b) {
  return (b == 0) ? abs(a) : gcd(b, a % b);
}
template <typename T>
inline T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <typename T>
inline T sqr(T x) {
  return x * x;
}
template <typename T>
inline string tostring(const T& x) {
  ostringstream os;
  os << x;
  return os.str();
}
inline int toint(const string& s) {
  istringstream is(s);
  int x;
  is >> x;
  return x;
}
inline long double todouble(const string& s) {
  istringstream is(s);
  long double x;
  is >> x;
  return x;
}
inline string tolower(string s) {
  for (typeof((s).begin()) it = (s).begin(); it != (s).end(); ++it)
    *it = tolower(*it);
  return s;
}
inline string toupper(string s) {
  for (typeof((s).begin()) it = (s).begin(); it != (s).end(); ++it)
    *it = toupper(*it);
  return s;
}
inline int todecimal(string s) {
  int a = 0;
  for (int i = 0; i < (s.size()); i++) a = 2 * a + (s[i] - '0');
  return a;
}
inline string tobinary(int a) {
  string s;
  while (a != 0) {
    s = (char)(a % 2 + '0') + s;
    a >>= 1;
  }
  return s;
}
inline int isvowel(char c) {
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') return 1;
  return 0;
}
inline int isprime(int a) {
  for (int i = 2; i * i <= a; i++)
    if (!(a % i)) return 0;
  return 1;
}
int n;
const int maxn = 100000;
int a[maxn + 1];
int b[maxn + 1];
vector<int> v;
void solve() {
  memset(b, 0, sizeof b);
  for (int i = 0; i < n; i++) {
    int tmp = a[i];
    int y = 0;
    for (int j = 2; j * j <= tmp; j++) {
      if (tmp % j == 0) {
        y = max(y, b[j] + 1);
        v.push_back(j);
        while (tmp % j == 0) tmp = tmp / j;
      }
    }
    if (tmp > 1) {
      y = max(y, b[tmp] + 1);
      v.push_back(tmp);
    }
    for (int i = 0; i < v.size(); i++) b[v[i]] = y;
    v.clear();
  }
  int ans = 1;
  for (int i = 1; i <= maxn; i++) ans = max(ans, b[i]);
  cout << ans << endl;
}
void input() {
  cin >> n;
  for (int i = 0; i < (n); i++) cin >> a[i];
}
int main() {
  int t = 1;
  for (int i = 1; i <= t; i++) {
    input();
    solve();
  }
  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;
const int INF = (int)1E9 + 5;
const long long LINF = (long long)4E18 + 5;
const long double PI = acos(-1.0);
const long double E = 2.718281828459045L;
const double EPS = 1.0e-9;
void debugarr(int* arr, int n) {
  cout << "[";
  for (int i = 0; i < n; i++) cout << arr[i] << " ";
  cout << "]" << endl;
}
template <typename T>
T gcd(T a, T b) {
  return (b == 0) ? abs(a) : gcd(b, a % b);
}
template <typename T>
inline T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <typename T>
inline T sqr(T x) {
  return x * x;
}
template <typename T>
inline string tostring(const T& x) {
  ostringstream os;
  os << x;
  return os.str();
}
inline int toint(const string& s) {
  istringstream is(s);
  int x;
  is >> x;
  return x;
}
inline long double todouble(const string& s) {
  istringstream is(s);
  long double x;
  is >> x;
  return x;
}
inline string tolower(string s) {
  for (typeof((s).begin()) it = (s).begin(); it != (s).end(); ++it)
    *it = tolower(*it);
  return s;
}
inline string toupper(string s) {
  for (typeof((s).begin()) it = (s).begin(); it != (s).end(); ++it)
    *it = toupper(*it);
  return s;
}
inline int todecimal(string s) {
  int a = 0;
  for (int i = 0; i < (s.size()); i++) a = 2 * a + (s[i] - '0');
  return a;
}
inline string tobinary(int a) {
  string s;
  while (a != 0) {
    s = (char)(a % 2 + '0') + s;
    a >>= 1;
  }
  return s;
}
inline int isvowel(char c) {
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') return 1;
  return 0;
}
inline int isprime(int a) {
  for (int i = 2; i * i <= a; i++)
    if (!(a % i)) return 0;
  return 1;
}
int n;
const int maxn = 100000;
int a[maxn + 1];
int b[maxn + 1];
vector<int> v;
void solve() {
  memset(b, 0, sizeof b);
  for (int i = 0; i < n; i++) {
    int tmp = a[i];
    int y = 0;
    for (int j = 2; j * j <= tmp; j++) {
      if (tmp % j == 0) {
        y = max(y, b[j] + 1);
        v.push_back(j);
        while (tmp % j == 0) tmp = tmp / j;
      }
    }
    if (tmp > 1) {
      y = max(y, b[tmp] + 1);
      v.push_back(tmp);
    }
    for (int i = 0; i < v.size(); i++) b[v[i]] = y;
    v.clear();
  }
  int ans = 1;
  for (int i = 1; i <= maxn; i++) ans = max(ans, b[i]);
  cout << ans << endl;
}
void input() {
  cin >> n;
  for (int i = 0; i < (n); i++) cin >> a[i];
}
int main() {
  int t = 1;
  for (int i = 1; i <= t; i++) {
    input();
    solve();
  }
  return 0;
}

```