#include <bits/stdc++.h>
using namespace std;
class EratospheneLinear {
 private:
  const int N;
  std::vector<int> lp, pr;

 public:
  EratospheneLinear(int n) : N(n), lp(std::vector<int>(N + 1, 0)) {
    for (int i = 2; i <= N; ++i) {
      if (lp[i] == 0) {
        lp[i] = i;
        pr.push_back(i);
      }
      for (int j = 0; j < (int)pr.size() && pr[j] <= lp[i] && i * pr[j] <= N;
           ++j)
        lp[i * pr[j]] = pr[j];
    }
  }
  bool isprime(int n) { return lp[n] == n; }
  std::unordered_map<int, int> factorize(int n) {
    std::unordered_map<int, int> ans;
    if (n == 1) {
      ans.insert(make_pair(1, 1));
      return ans;
    }
    while (n > 1) {
      std::unordered_map<int, int>::iterator it = ans.find(lp[n]);
      if (it == ans.end())
        ans.insert(std::make_pair(lp[n], 1));
      else
        ++it->second;
      n /= lp[n];
    }
    return ans;
  }
};
bool merge(unordered_map<int, int>& base, unordered_map<int, int>& len,
           unordered_map<int, int> addition) {
  bool is_coprime = true;
  for (unordered_map<int, int>::iterator ita = addition.begin();
       ita != addition.end(); ++ita) {
    unordered_map<int, int>::iterator itb = base.find(ita->first);
    if (itb == base.end()) {
      base.insert(make_pair(ita->first, ita->second));
    } else {
      is_coprime = false;
      itb->second = itb->second + ita->second - min(itb->second, ita->second);
    }
  }
  int maxlen = 0;
  for (unordered_map<int, int>::iterator ita = addition.begin();
       ita != addition.end(); ++ita) {
    unordered_map<int, int>::iterator itl = len.find(ita->first);
    if (itl != len.end()) {
      maxlen = max(itl->second, maxlen);
    }
  }
  for (unordered_map<int, int>::iterator ita = addition.begin();
       ita != addition.end(); ++ita) {
    unordered_map<int, int>::iterator itl = len.find(ita->first);
    if (itl == len.end()) {
      len.insert(make_pair(ita->first, maxlen + 1));
    } else {
      itl->second = maxlen + 1;
    }
  }
  return is_coprime;
}
template <typename In, typename Out>
void solve(In& in, Out& out) {
  EratospheneLinear sito(1000000);
  int n, x, ans = 0;
  in >> n;
  unordered_map<int, int> base, len;
  for (int i = 0; i < n; ++i) {
    in >> x;
    merge(base, len, sito.factorize(x));
  }
  for (unordered_map<int, int>::iterator it = len.begin(); it != len.end();
       ++it)
    ans = max(ans, it->second);
  out << ans;
}
int main() {
  solve(cin, cout);
  return 0;
}
