#include <bits/stdc++.h>
using namespace std;
int getInt() {
  int x;
  scanf("%d", &x);
  return x;
}
long long getLongLong() {
  long long x;
  scanf("%I64d", &x);
  return x;
}
double getDouble() {
  double x;
  scanf("%lf", &x);
  return x;
}
char getChar() {
  char x;
  scanf("%c", &x);
  return x;
}
template <typename t>
t abs(t a) {
  if (a >= 0) return a;
  return -a;
}
vector<string> split(const string& s, char c) {
  vector<string> v;
  stringstream second(s);
  string x;
  while (getline(second, x, c)) v.emplace_back(x);
  return move(v);
}
void err(vector<string>::iterator it) {}
template <typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
  cout << it->substr((*it)[0] == ' ', it->length()) << " = " << a << "  ";
  err(++it, args...);
}
void FastIO() {
  ios::sync_with_stdio(0);
  cin.tie(0);
}
int a[112345] = {0};
int dp[112345][2] = {0};
int n;
const int Max = 100345;
vector<int> nxt[Max];
vector<int> pf[Max];
bool pr[Max] = {1, 1};
vector<int> nxti[Max];
int itr = 0;
int calc(int x = 0, bool taken = 0) {
  if (x >= n) return 0;
  int& ans = dp[x][taken];
  if (ans != -1) return ans;
  ans = 0;
  if (taken)
    for (auto v : nxt[x]) {
      ans = max(ans, calc(v, 1) + 1);
    }
  else {
    ans = max(ans, max(calc(x + 1, 0), calc(x + 1, 1) + 1));
  }
  return ans;
}
int sol() {
  for (int i = 0; i < n; i++) {
    dp[i][1] = 1;
    dp[i][0] = 0;
  }
  for (int i = n - 1; i >= 0; i--) {
    for (auto v : nxt[i]) {
      dp[i][1] = max(dp[i][1], 1 + dp[v][1]);
    }
    dp[i][0] = max(dp[i + 1][0], dp[i + 1][1]);
  }
  return max(dp[0][0], dp[0][1]);
}
void pre() {
  for (int i = 2; i < Max; i++) {
    if (!pr[i]) {
      pf[i].push_back(i);
      for (long long j = (long long)i + (long long)i; j < Max; j += i) {
        pr[j] = 1;
        pf[j].push_back(i);
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (auto v : pf[a[i]]) nxti[v].push_back(i);
  }
  for (int i = 0; i < Max; i++) {
    for (int j = 1; j < nxti[i].size(); j++) {
      nxt[nxti[i][j - 1]].push_back(nxti[i][j]);
    }
  }
}
int main() {
  n = getInt();
  for (int i = 0; i < n; i++) a[i] = getInt();
  pre();
  memset(dp, -1, sizeof dp);
  cout << max(calc(0, 0), 1 + calc(0, 1)) << endl;
  return 0;
}

### Prompt

Please formulate 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;
int getInt() {
  int x;
  scanf("%d", &x);
  return x;
}
long long getLongLong() {
  long long x;
  scanf("%I64d", &x);
  return x;
}
double getDouble() {
  double x;
  scanf("%lf", &x);
  return x;
}
char getChar() {
  char x;
  scanf("%c", &x);
  return x;
}
template <typename t>
t abs(t a) {
  if (a >= 0) return a;
  return -a;
}
vector<string> split(const string& s, char c) {
  vector<string> v;
  stringstream second(s);
  string x;
  while (getline(second, x, c)) v.emplace_back(x);
  return move(v);
}
void err(vector<string>::iterator it) {}
template <typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
  cout << it->substr((*it)[0] == ' ', it->length()) << " = " << a << "  ";
  err(++it, args...);
}
void FastIO() {
  ios::sync_with_stdio(0);
  cin.tie(0);
}
int a[112345] = {0};
int dp[112345][2] = {0};
int n;
const int Max = 100345;
vector<int> nxt[Max];
vector<int> pf[Max];
bool pr[Max] = {1, 1};
vector<int> nxti[Max];
int itr = 0;
int calc(int x = 0, bool taken = 0) {
  if (x >= n) return 0;
  int& ans = dp[x][taken];
  if (ans != -1) return ans;
  ans = 0;
  if (taken)
    for (auto v : nxt[x]) {
      ans = max(ans, calc(v, 1) + 1);
    }
  else {
    ans = max(ans, max(calc(x + 1, 0), calc(x + 1, 1) + 1));
  }
  return ans;
}
int sol() {
  for (int i = 0; i < n; i++) {
    dp[i][1] = 1;
    dp[i][0] = 0;
  }
  for (int i = n - 1; i >= 0; i--) {
    for (auto v : nxt[i]) {
      dp[i][1] = max(dp[i][1], 1 + dp[v][1]);
    }
    dp[i][0] = max(dp[i + 1][0], dp[i + 1][1]);
  }
  return max(dp[0][0], dp[0][1]);
}
void pre() {
  for (int i = 2; i < Max; i++) {
    if (!pr[i]) {
      pf[i].push_back(i);
      for (long long j = (long long)i + (long long)i; j < Max; j += i) {
        pr[j] = 1;
        pf[j].push_back(i);
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (auto v : pf[a[i]]) nxti[v].push_back(i);
  }
  for (int i = 0; i < Max; i++) {
    for (int j = 1; j < nxti[i].size(); j++) {
      nxt[nxti[i][j - 1]].push_back(nxti[i][j]);
    }
  }
}
int main() {
  n = getInt();
  for (int i = 0; i < n; i++) a[i] = getInt();
  pre();
  memset(dp, -1, sizeof dp);
  cout << max(calc(0, 0), 1 + calc(0, 1)) << endl;
  return 0;
}

```