/* -*- coding: utf-8 -*- * * 2218.cc: No.2218 Multiple LIS - yukicoder */ #include #include using namespace std; /* constant */ const int MAX_N = 100000; const int MAX_A = 100000; /* typedef */ /* global variables */ int as[MAX_N], dp[MAX_A + 1]; /* subroutines */ inline void setmax(int &a, int b) { if (a < b) a = b; } /* main */ int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", as + i); for (int i = n - 1; i >= 0; i--) { int ai = as[i]; dp[ai]++; for (int p = 2; p * p <= ai; p++) if (ai % p == 0) { int q = ai / p; setmax(dp[p], dp[ai]); setmax(dp[q], dp[ai]); } setmax(dp[1], dp[ai]); } printf("%d\n", *max_element(dp, dp + MAX_A + 1)); return 0; }