#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << ",  ";
  err(++it, args...);
}
long long int power(long long int x, long long int b) {
  long long int p = 1;
  while (b > 0) {
    if (b & 1) {
      p = p * x;
      p %= 1000000007;
    }
    b >>= 1;
    x *= x;
    x %= 1000000007;
  }
  return p % 1000000007;
}
std::vector<long long int> fact;
void fact_pre(long long int n = 1100000) {
  fact.resize(n, 1);
  for (long long int i = 2; i < n; i++)
    fact[i] = (fact[i - 1] * i) % 1000000007;
}
long long int ncr(long long int n, long long int r) {
  if (r > n) return 0;
  return (fact[n] *
          power((fact[n - r] * fact[r]) % 1000000007, 1000000007 - 2)) %
         1000000007;
}
mt19937_64 rang(
    chrono::high_resolution_clock::now().time_since_epoch().count());
long long int rng(long long int lim, long long int s = 0) {
  uniform_int_distribution<long long int> uid(s, lim - 1);
  return uid(rang);
}
struct ppp {
  long double first, second, tt;
};
bool comp(pair<pair<long long int, long long int>, long long int> &p1,
          pair<pair<long long int, long long int>, long long int> &p2) {
  if (p1.first.first == p2.first.first) {
    return p1.first.second > p2.first.second;
  } else {
    return p1.first.first < p2.first.first;
  }
}
long long int bsleft(vector<long long int> &arr, long long int c) {
  long long int l = -1, r = arr.size();
  while (r - l > 1) {
    long long int mid = (r + l) / 2;
    if (arr[mid] <= c) {
      l = mid;
    } else {
      r = mid;
    }
  }
  return l;
}
struct lex_compare {
  bool operator()(
      const pair<long long int, pair<long long int, long long int>> &p1,
      const pair<long long int, pair<long long int, long long int>> &p2) {
    return p1 < p2;
  }
};
long long int N = 100005;
vector<long long int> smallest(100005, 0);
vector<long long int> primes;
void sieve() {
  iota(smallest.begin(), smallest.end(), 0);
  for (long long int i = 2; i < N; i++) {
    if (smallest[i] == i) primes.push_back(i);
    for (auto j : primes) {
      if (i * j >= N) break;
      if (j > smallest[i]) break;
      smallest[i * j] = j;
    }
  }
  return;
}
vector<long long int> factors(long long int x) {
  vector<long long int> ans;
  while (x > 1) {
    long long int y = smallest[x];
    ans.push_back(y);
    while (x % y == 0) x /= y;
  }
  return ans;
}
void solve() {
  long long int n;
  cin >> n;
  vector<long long int> arr(n);
  for (long long int i = 0; i < n; i++) cin >> arr[i];
  vector<long long int> dp(100005, 0);
  vector<long long int> freq(100005, 0);
  for (auto i : arr) freq[i]++;
  long long int op = 0;
  dp[1] = 0;
  for (auto i : arr) {
    vector<long long int> temp = factors(i);
    long long int z = 0;
    for (auto j : temp) {
      z = max(z, dp[j]);
    }
    z += 1;
    for (auto j : temp) {
      dp[j] = max(dp[j], z);
    }
  }
  op = *max_element(dp.begin() + 1, dp.end());
  op = max(op, 1LL);
  cout << op << "\n";
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long int t;
  t = 1;
  ;
  sieve();
  for (long long int i = 1; i < t + 1; i++) {
    solve();
  }
  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>
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << ",  ";
  err(++it, args...);
}
long long int power(long long int x, long long int b) {
  long long int p = 1;
  while (b > 0) {
    if (b & 1) {
      p = p * x;
      p %= 1000000007;
    }
    b >>= 1;
    x *= x;
    x %= 1000000007;
  }
  return p % 1000000007;
}
std::vector<long long int> fact;
void fact_pre(long long int n = 1100000) {
  fact.resize(n, 1);
  for (long long int i = 2; i < n; i++)
    fact[i] = (fact[i - 1] * i) % 1000000007;
}
long long int ncr(long long int n, long long int r) {
  if (r > n) return 0;
  return (fact[n] *
          power((fact[n - r] * fact[r]) % 1000000007, 1000000007 - 2)) %
         1000000007;
}
mt19937_64 rang(
    chrono::high_resolution_clock::now().time_since_epoch().count());
long long int rng(long long int lim, long long int s = 0) {
  uniform_int_distribution<long long int> uid(s, lim - 1);
  return uid(rang);
}
struct ppp {
  long double first, second, tt;
};
bool comp(pair<pair<long long int, long long int>, long long int> &p1,
          pair<pair<long long int, long long int>, long long int> &p2) {
  if (p1.first.first == p2.first.first) {
    return p1.first.second > p2.first.second;
  } else {
    return p1.first.first < p2.first.first;
  }
}
long long int bsleft(vector<long long int> &arr, long long int c) {
  long long int l = -1, r = arr.size();
  while (r - l > 1) {
    long long int mid = (r + l) / 2;
    if (arr[mid] <= c) {
      l = mid;
    } else {
      r = mid;
    }
  }
  return l;
}
struct lex_compare {
  bool operator()(
      const pair<long long int, pair<long long int, long long int>> &p1,
      const pair<long long int, pair<long long int, long long int>> &p2) {
    return p1 < p2;
  }
};
long long int N = 100005;
vector<long long int> smallest(100005, 0);
vector<long long int> primes;
void sieve() {
  iota(smallest.begin(), smallest.end(), 0);
  for (long long int i = 2; i < N; i++) {
    if (smallest[i] == i) primes.push_back(i);
    for (auto j : primes) {
      if (i * j >= N) break;
      if (j > smallest[i]) break;
      smallest[i * j] = j;
    }
  }
  return;
}
vector<long long int> factors(long long int x) {
  vector<long long int> ans;
  while (x > 1) {
    long long int y = smallest[x];
    ans.push_back(y);
    while (x % y == 0) x /= y;
  }
  return ans;
}
void solve() {
  long long int n;
  cin >> n;
  vector<long long int> arr(n);
  for (long long int i = 0; i < n; i++) cin >> arr[i];
  vector<long long int> dp(100005, 0);
  vector<long long int> freq(100005, 0);
  for (auto i : arr) freq[i]++;
  long long int op = 0;
  dp[1] = 0;
  for (auto i : arr) {
    vector<long long int> temp = factors(i);
    long long int z = 0;
    for (auto j : temp) {
      z = max(z, dp[j]);
    }
    z += 1;
    for (auto j : temp) {
      dp[j] = max(dp[j], z);
    }
  }
  op = *max_element(dp.begin() + 1, dp.end());
  op = max(op, 1LL);
  cout << op << "\n";
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long int t;
  t = 1;
  ;
  sieve();
  for (long long int i = 1; i < t + 1; i++) {
    solve();
  }
  return 0;
}

```