#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); };
int len[100100], a[100100], primes[100100], primesc = 0;
int main() {
  memset(len, 0, sizeof(len));
  int n;
  cin >> n;
  primesc = 1;
  primes[0] = 2;
  for (int i = 3; i * i < 100100; i += 2) {
    bool prime = true;
    for (int j = 0; j < primesc and primes[j] * primes[j] <= i and prime; j++) {
      if ((i % primes[j]) == 0) prime = false;
    }
    if (prime) primes[primesc++] = i;
  }
  for (int i = 0; i < n; i++) cin >> a[i];
  if (n == 1 and a[0] == 1) {
    cout << 1 << endl;
    return 0;
  }
  for (int i = n - 1; i >= 0; i--) {
    vector<int> factors;
    int maxseq = 0;
    for (int j = 0; j < primesc; j++) {
      if (a[i] % primes[j] == 0) {
        len[primes[j]]++;
        factors.push_back(primes[j]);
        if (len[primes[j]] > len[maxseq]) maxseq = primes[j];
        while ((a[i] % primes[j]) == 0) a[i] /= primes[j];
      }
    }
    if (a[i] > 1) {
      len[a[i]]++;
      factors.push_back(a[i]);
      if (len[a[i]] > len[maxseq]) maxseq = a[i];
    }
    for (int j = 0; j < factors.size(); j++) {
      if (factors[j] != maxseq) len[factors[j]] = len[maxseq];
    }
  }
  cout << *max_element(len, len + 100010) << endl;
  return 0;
}
