#include <bits/stdc++.h>
using namespace std;
const int mxn = 2e5 + 10;
int sp[mxn], arr[mxn];
vector<int> required[mxn], bit[mxn];
int ask(int p, int x) {
  int idx = lower_bound(required[p].begin(), required[p].end(), x) -
            required[p].begin();
  int ret = 0;
  while (idx > 0) ret = max(ret, bit[p][idx]), idx -= idx & -idx;
  return ret;
}
void update(int p, int x, int v) {
  int idx = lower_bound(required[p].begin(), required[p].end(), x) -
            required[p].begin() + 1;
  while (idx <= required[p].size())
    bit[p][idx] = max(v, bit[p][idx]), idx += idx & -idx;
}
int main() {
  sp[1] = 1;
  for (int i = 2; i < mxn; i++) {
    if (sp[i]) continue;
    for (int j = i; j < mxn; j += i) sp[j] = sp[j] == 0 ? i : sp[j];
  }
  int n, x, ret = 1;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &arr[i]), x = arr[i];
    while (x != 1) {
      int p = sp[x];
      while (p == sp[x]) x /= p;
      required[p].push_back(arr[i]);
    }
  }
  for (int i = 1; i < mxn; i++) {
    sort(required[i].begin(), required[i].end());
    required[i].erase(unique(required[i].begin(), required[i].end()),
                      required[i].end());
    bit[i] = vector<int>(required[i].size() + 1, 0);
  }
  for (int i = 1; i <= n; i++) {
    x = arr[i];
    int curr = 0;
    while (x != 1) {
      int p = sp[x];
      while (p == sp[x]) x /= p;
      curr = max(curr, 1 + ask(p, arr[i]));
    }
    ret = max(ret, curr);
    x = arr[i];
    while (x != 1) {
      int p = sp[x];
      while (p == sp[x]) x /= p;
      update(p, arr[i], curr);
    }
  }
  printf("%d\n", ret);
}
