#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T power(T base, int p) {
  T f = 1;
  for (int i = 1; i <= p; i++) f *= base;
  return f;
}
template <typename T>
string NumberToString(T Number) {
  ostringstream ss;
  ss << Number;
  return ss.str();
}
int setbit(int N, int pos) { return N = N | (1 << pos); }
int resetbit(int N, int pos) { return N = N & ~(1 << pos); }
bool checkbit(int N, int pos) { return (bool)(N & 1 << pos); }
pair<long long int, long long int> extendedEuclid(int a, int b) {
  if (b == 0) return pair<long long int, long long int>(1, 0);
  pair<long long int, long long int> d = extendedEuclid(b, a % b);
  return pair<long long int, long long int>(d.second,
                                            d.first - d.second * (a / b));
}
int modularInverse(int a, int m) {
  pair<long long int, long long int> ret = extendedEuclid(a, m);
  return ret.first % m;
}
int dp[1000002 + 2];
int arr[1000002 + 2];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int a;
    scanf("%d", &a);
    dp[a] = 1;
  }
  for (int i = 1; i <= 1000002; i++) {
    if (dp[i])
      for (int j = i * 2; j <= 1000002; j += i) {
        if (dp[j]) dp[j] = max(dp[j], dp[i] + 1);
      }
  }
  int ans = -1;
  for (int i = 1; i <= 1000002 + 1; i++) {
    ans = max(ans, dp[i]);
  }
  cout << ans << endl;
}
