#include <bits/stdc++.h>
using namespace std;
long long ncr(long long n, long long r) {
  long long i, ans = 1, k = 0;
  if (r == 0)
    return 1;
  else if (n < r)
    return 0;
  for (i = n; i >= n - r + 1; i--) {
    ans *= i;
    ans /= n - i + 1;
  }
  return ans;
}
bool visited[6] = {false};
int n = 6;
vector<int> adj[6];
void max_heapify(int a[100], int i) {
  int l, r, largest = i;
  l = 2 * i + 1;
  r = 2 * i + 2;
  if (l < n && a[l] > a[i]) largest = l;
  if (r < n && a[r] > a[l]) largest = r;
  if (largest != i) {
    int k;
    k = a[i];
    a[i] = a[largest];
    a[largest] = k;
    max_heapify(a, largest);
  }
}
int power(long long x, long long y, long long p) {
  int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
bool square(long long n) {
  double x;
  x = sqrt(n);
  if (x == floor(x))
    return true;
  else
    return false;
}
bool prime(long long n) {
  long long i;
  for (i = 2; i * i <= n; i++) {
    if (n % i == 0) return false;
  }
  return true;
}
long long modi(long long a, long long m) { return power(a, m - 2, m); }
void kmp(string s, long long p[]) {
  int n = (int)s.length();
  p[0] = 0;
  for (int i = 1; i < n; i++) {
    int j = p[i - 1];
    while (j > 0 && s[i] != s[j]) j = p[j - 1];
    if (s[i] == s[j]) j++;
    p[i] = j;
  }
}
void zfunc(string s, long long z[]) {
  long long n = (long long)s.length();
  z[0] = 0;
  for (long long i = 1, l = 0, r = 0; i < n; ++i) {
    if (i <= r) z[i] = min(r - i + 1, z[i - l]);
    while (i + z[i] < n && s[z[i]] == s[i + z[i]]) ++z[i];
    if (i + z[i] - 1 > r) l = i, r = i + z[i] - 1;
  }
}
struct pair_hash {
  size_t operator()(const pair<int, int>& p) const noexcept {
    return hash<long long>()((((long long)p.first) << 32) |
                             ((long long)p.second));
  }
};
bool palin(string s) {
  long long i, n;
  n = s.length();
  for (i = 0; i <= n / 2; i++) {
    if (s[i] != s[n - i - 1]) {
      return false;
    }
  }
  return true;
}
long long sum(long long n) {
  long long i;
  i = n;
  long long sum = 0;
  while (i > 0) {
    sum += i % 10;
    i = i / 10;
  }
  return sum;
}
long long nCr(long long n, long long r, long long p, long long fac[]) {
  if (r == 0) return 1;
  fac[0] = 1;
  for (int i = 1; i <= n; i++) fac[i] = fac[i - 1] * i % p;
  return (fac[n] * modi(fac[r], p) % p * modi(fac[n - r], p) % p) % p;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
void bfs(vector<long long>& ans, long long k) {
  queue<long long> q;
  while (!q.empty()) {
    long long temp = q.front();
  }
}
void solve(long long l, long long r) {
  if (l >= r) {
    return;
  }
  if ((r - l) % 2 == 1) {
    long long start = (r + l) / 2 + 1;
    long long k = -1, j = 1;
    while (start != l) {
      printf("%lld %lld\n", start, start + k * j);
      if (start + k * j == l) {
        break;
      }
      start += k * j;
      j++;
      k *= -1;
    }
  } else {
    long long start = (r + l) / 2;
    long long k = 1, j = 1;
    while (start != l) {
      printf("%lld %lld\n", start, start + k * j);
      if (start + k * j == l) {
        break;
      }
      start += k * j;
      j++;
      k *= -1;
    }
  }
}
void dfs(long long start, vector<long long> adj[], bool visited[],
         long long dp[], long long& maxi) {
  visited[start] = true;
  for (auto u : adj[start]) {
    if (!visited[u]) {
      visited[u] = true;
      dp[u] = max(dp[u], dp[start] + 1);
      dfs(u, adj, visited, dp, maxi);
      maxi = max(maxi, dp[u]);
    }
  }
}
double fab(double x) {
  if (x < 0) {
    return -x;
  }
  return x;
}
int main() {
  long long t = 1, i, j, x, u, v;
  while (t--) {
    long long n;
    cin >> n;
    vector<long long> v(n);
    for (i = 0; i < n; i++) {
      cin >> v[i];
    }
    long long dp[100001] = {0};
    dp[0] = 0;
    vector<long long> factor[100001];
    vector<bool> primesieve(100001, true);
    factor[1].push_back(1);
    for (i = 2; i <= 100000; i++) {
      if (primesieve[i]) {
        factor[i].push_back(i);
        for (j = i + i; j <= 100000; j += i) {
          primesieve[j] = false;
          factor[j].push_back(i);
        }
      }
    }
    long long ans = 1;
    for (i = 0; i < n; i++) {
      long long maxi = 0;
      for (auto u : factor[v[i]]) {
        maxi = max(maxi, dp[u]);
      }
      for (auto u : factor[v[i]]) {
        dp[u] = maxi + 1;
      }
      ans = max(ans, maxi + 1);
    }
    cout << ans;
  }
  return 0;
}
