#include <bits/stdc++.h>
using namespace std;
bool primecheck(long long int a) {
  bool check = true;
  if (a == 1) return (false);
  for (long long int i = 2; i <= sqrt(a); i++) {
    if (a % i == 0) {
      check = false;
      break;
    }
  }
  return (check);
}
vector<long long int> primeFactors(long long int n) {
  vector<long long int> sol;
  bool once = false;
  while (n % 2 == 0) {
    if (!once) {
      sol.push_back(2);
      once = true;
    }
    n = n / 2;
  }
  for (int i = 3; i <= sqrt(n); i = i + 2) {
    bool once = false;
    while (n % i == 0) {
      if (!once) {
        sol.push_back(i);
        once = true;
      }
      n = n / i;
    }
  }
  if (n > 2) {
    sol.push_back(n);
  }
  return (sol);
}
vector<long long int> printDivisors(long long int n) {
  vector<long long int> sol;
  for (long long int i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      if (n / i == i) {
        sol.push_back(i);
      } else {
        sol.push_back(i);
        sol.push_back(n / i);
      }
    }
  }
  return (sol);
}
long long int digits(long long int a) { return (floor(log10(a)) + 1); }
long long int bits(long long int n) { return __builtin_popcount(n); }
long long binpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = res * a % m;
    a = a * a % m;
    b >>= 1;
  }
  return res;
}
long long int modInverse(long long int a, long long int m) {
  long long int m0 = m;
  long long int y = 0, x = 1;
  if (m == 1) return 0;
  while (a > 1) {
    long long int q = a / m;
    long long int t = m;
    m = a % m, a = t;
    t = y;
    y = x - q * y;
    x = t;
  }
  if (x < 0) x += m0;
  return x;
}
int gcd(int a, int b) {
  if (a == 0) return b;
  if (b == 0) return a;
  if (a == b) return a;
  if (a > b) return gcd(a - b, b);
  return gcd(a, b - a);
}
long long int lcm(long long int a, long long int b) {
  return (a * b) / gcd(a, b);
}
void addEdge(vector<long long int> adj[], long long int u, long long int v) {
  adj[u].push_back(v);
  adj[v].push_back(u);
}
vector<long long int> path;
void dfs(long long int u, vector<long long int> adj[], vector<bool> &visited,
         long long int parent = -1) {
  visited[u] = true;
  path[u] = parent;
  for (long long int i = 0; i < adj[u].size(); i++) {
    if (visited[adj[u][i]] == false) {
      dfs(adj[u][i], adj, visited, u);
    }
  }
}
long long int a;
long long int arr[100005];
long long int mem[100005];
void calc(long long int num) {
  vector<long long int> divs = printDivisors(num);
  long long int maxie = 1;
  long long int i, j;
  for (i = 0; i < divs.size(); i++) {
    if (divs[i] == 1) {
      continue;
    }
    if (mem[divs[i]] != -1) {
      maxie = max(maxie, mem[divs[i]] + 1);
    }
  }
  mem[num] = maxie;
  for (i = 0; i < divs.size(); i++) {
    if (divs[i] == 1) {
      continue;
    }
    mem[divs[i]] = max(mem[divs[i]], maxie);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int b, c, i, j, k, l, m, n, t, p;
  cin >> a;
  memset(mem, -1, sizeof(mem));
  for (i = 0; i < a; i++) cin >> arr[i];
  for (i = 0; i < a; i++) {
    calc(arr[i]);
  }
  sort(mem, mem + 100005);
  reverse(mem, mem + 100005);
  cout << mem[0] << "\n";
}

### Prompt

Your challenge is to write 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;
bool primecheck(long long int a) {
  bool check = true;
  if (a == 1) return (false);
  for (long long int i = 2; i <= sqrt(a); i++) {
    if (a % i == 0) {
      check = false;
      break;
    }
  }
  return (check);
}
vector<long long int> primeFactors(long long int n) {
  vector<long long int> sol;
  bool once = false;
  while (n % 2 == 0) {
    if (!once) {
      sol.push_back(2);
      once = true;
    }
    n = n / 2;
  }
  for (int i = 3; i <= sqrt(n); i = i + 2) {
    bool once = false;
    while (n % i == 0) {
      if (!once) {
        sol.push_back(i);
        once = true;
      }
      n = n / i;
    }
  }
  if (n > 2) {
    sol.push_back(n);
  }
  return (sol);
}
vector<long long int> printDivisors(long long int n) {
  vector<long long int> sol;
  for (long long int i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      if (n / i == i) {
        sol.push_back(i);
      } else {
        sol.push_back(i);
        sol.push_back(n / i);
      }
    }
  }
  return (sol);
}
long long int digits(long long int a) { return (floor(log10(a)) + 1); }
long long int bits(long long int n) { return __builtin_popcount(n); }
long long binpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = res * a % m;
    a = a * a % m;
    b >>= 1;
  }
  return res;
}
long long int modInverse(long long int a, long long int m) {
  long long int m0 = m;
  long long int y = 0, x = 1;
  if (m == 1) return 0;
  while (a > 1) {
    long long int q = a / m;
    long long int t = m;
    m = a % m, a = t;
    t = y;
    y = x - q * y;
    x = t;
  }
  if (x < 0) x += m0;
  return x;
}
int gcd(int a, int b) {
  if (a == 0) return b;
  if (b == 0) return a;
  if (a == b) return a;
  if (a > b) return gcd(a - b, b);
  return gcd(a, b - a);
}
long long int lcm(long long int a, long long int b) {
  return (a * b) / gcd(a, b);
}
void addEdge(vector<long long int> adj[], long long int u, long long int v) {
  adj[u].push_back(v);
  adj[v].push_back(u);
}
vector<long long int> path;
void dfs(long long int u, vector<long long int> adj[], vector<bool> &visited,
         long long int parent = -1) {
  visited[u] = true;
  path[u] = parent;
  for (long long int i = 0; i < adj[u].size(); i++) {
    if (visited[adj[u][i]] == false) {
      dfs(adj[u][i], adj, visited, u);
    }
  }
}
long long int a;
long long int arr[100005];
long long int mem[100005];
void calc(long long int num) {
  vector<long long int> divs = printDivisors(num);
  long long int maxie = 1;
  long long int i, j;
  for (i = 0; i < divs.size(); i++) {
    if (divs[i] == 1) {
      continue;
    }
    if (mem[divs[i]] != -1) {
      maxie = max(maxie, mem[divs[i]] + 1);
    }
  }
  mem[num] = maxie;
  for (i = 0; i < divs.size(); i++) {
    if (divs[i] == 1) {
      continue;
    }
    mem[divs[i]] = max(mem[divs[i]], maxie);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int b, c, i, j, k, l, m, n, t, p;
  cin >> a;
  memset(mem, -1, sizeof(mem));
  for (i = 0; i < a; i++) cin >> arr[i];
  for (i = 0; i < a; i++) {
    calc(arr[i]);
  }
  sort(mem, mem + 100005);
  reverse(mem, mem + 100005);
  cout << mem[0] << "\n";
}

```