#include <bits/stdc++.h>
using namespace std;
const int N = 100005, inf = 100000000;
long long gcd(long long a, long long b) {
  if (b == 0) {
    return a;
  } else {
    return gcd(b, a % b);
  }
}
int a[N], dp[N];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  dp[0] = 0;
  for (int i = 1; i <= n; ++i) {
    int& res = dp[i];
    res = 1;
    for (int j = i - 1; j >= 1 && i - j <= 100; --j) {
      if (gcd(a[i - 1], a[j - 1]) > 1) {
        res = max(res, 1 + dp[j]);
      }
    }
  }
  int res = 0;
  for (int i = 0; i <= n; ++i) {
    res = max(res, dp[i]);
  }
  printf("%d\n", res);
  return (0);
}
