#include <bits/stdc++.h>
using namespace std;
int n;
;
int a[100005];
int d[100005];
vector<vector<int> > di;
vector<int> v;
bool arr[100005];
int main() {
  di.assign(100005, v);
  for (int i = 2; i <= 100000; i++)
    if (!arr[i]) {
      di[i].push_back(i);
      for (int j = i + i; j <= 100000; j += i) {
        arr[j] = 1;
        di[j].push_back(i);
      }
    }
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int MAX = 0;
    for (int j = 0; j < di[a[i]].size(); j++) MAX = max(MAX, d[di[a[i]][j]]);
    MAX++;
    ans = max(ans, MAX);
    for (int j = 0; j < di[a[i]].size(); j++)
      d[di[a[i]][j]] = max(MAX, d[di[a[i]][j]]);
  }
  printf("%d\n", ans);
  return 0;
}
