#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define chmax(x, y) x = max(x, y) #define chmin(x, y) x = min(x, y) typedef long long ll; typedef uint64_t ull; typedef pair P; typedef pair Pid; typedef pair Pdi; typedef pair Pl; typedef pair Pll; typedef pair> PP; typedef pair PPi; constexpr double PI = 3.1415926535897932; // acos(-1) constexpr double EPS = 1e-9; constexpr int INF = 1001001001; constexpr int mod = 1e+9 + 7; // constexpr int mod = 998244353; vector divisor(int x){ vector res; for(int i = 1; (ll)i * i <= x; ++i){ if(x % i == 0){ res.push_back(i); if(i * i != x) res.push_back(x / i); } } sort(res.begin(), res.end()); return res; } vector> pos(300005); vector dp; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector a(n); for(int i = 0; i < n; ++i){ cin >> a[i]; pos[a[i]].push_back(i); } dp.assign(n, 1); for(int i = n - 1; i > 0; --i){ vector div = divisor(a[i]); int sz = div.size(); for(int j = 0; j < sz - 1; ++j){ cerr << div[j] << " "; auto it = lower_bound(pos[div[j]].begin(), pos[div[j]].end(), i); if(it == pos[div[j]].begin()) continue; int p = it - pos[div[j]].begin() - 1; cerr << p << " "; chmax(dp[pos[div[j]][p]], dp[i] + 1); } cerr << endl; } cout << *max_element(dp.begin(), dp.end()) << endl; }