#include <bits/stdc++.h>
using namespace std;
long N, A[100000], f[100000];
long gdc(long a, long b) {
  if (a == 0)
    return b;
  else
    gdc(b % a, a);
}
int main() {
  cin >> N;
  long t;
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
    t = 0;
    for (int j = max(1, i - 100); j <= i - 1; j++)
      if (gdc(A[i], A[j]) > 1) t = max(t, f[j]);
    f[i] = t + 1;
  }
  t = 0;
  for (long i = 1; i <= N; i++) {
    t = max(t, f[i]);
  }
  cout << t;
}
