#include <bits/stdc++.h>
using namespace std;
int n, num[100009], dp[100009];
int main() {
  while (scanf("%d", &n) == 1) {
    int maxi = -1, result = -1;
    ;
    for (int i = int(0); i < int(n); i++) {
      scanf("%d", &num[i]);
      int maxi = 0;
      for (int j = 2; j * j <= num[i]; j++) {
        if (num[i] % j == 0)
          maxi = max(maxi, dp[j]), maxi = max(maxi, dp[num[i] / j]);
      }
      maxi = max(maxi, dp[num[i]]);
      result = max(result, maxi + 1);
      for (int j = 2; j * j <= num[i]; j++) {
        if (num[i] % j == 0) dp[j] = maxi + 1, dp[num[i] / j] = maxi + 1;
      }
      dp[num[i]] = maxi + 1;
    }
    cout << result << endl;
  }
  return 0;
}
