#include <bits/stdc++.h>
using namespace std;
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b);
unsigned long long int gcd(unsigned long long int a, unsigned long long int b);
int prime(long long int n);
long long int power(long long int x, long long int y);
long long int nCr(long long int n, long long int r, long long int p);
void solve() {
  long long int n, ans = 1;
  cin >> n;
  long long int a[n];
  unordered_map<long long int, long long int> m;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = n - 1; i >= 0; i--) {
    long long int ans1 = 0;
    for (int j = 2; j <= sqrt(a[i]); j++) {
      if (a[i] % j == 0) {
        ans1 = max(ans1, m[j]);
      }
      if (a[i] % j == 0 && j != a[i] / j && a[i] / j != 1) {
        ans1 = max(ans1, m[a[i] / j]);
      }
    }
    ans1 = max(ans1, m[a[i]]);
    for (int j = 2; j <= sqrt(a[i]); j++) {
      if (a[i] % j == 0) {
        m[j] = ans1 + 1;
      }
      if (a[i] % j == 0 && j != a[i] / j && a[i] / j != 1) {
        m[a[i] / j] = ans1 + 1;
      }
    }
    m[a[i]] = ans1 + 1;
    ans = max(ans, ans1 + 1);
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t = 1, p = 0;
  while (t-- && ++p) {
    solve();
  }
}
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second < b.second);
}
unsigned long long int gcd(unsigned long long int a, unsigned long long int b) {
  if (a == 1 || b == 1) return 1;
  if (b == 0) return a;
  return gcd(b, a % b);
}
int prime(long long int n) {
  int flag = 1;
  for (long long int i = 2; i <= sqrt(n); i++) {
    if (n % i == 0) {
      flag = 0;
      break;
    }
  }
  return flag;
}
long long int power(long long int x, long long int y) {
  long long int temp;
  if (y == 0) return 1;
  temp = power(x, y / 2) % 1000000007;
  if (y % 2 == 0)
    return (temp * temp) % 1000000007;
  else
    return (((x * temp) % 1000000007) * temp) % 1000000007;
}
