#ifdef LOCAL //#define _GLIBCXX_DEBUG #else #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") //#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl") #endif #include using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair P; typedef pair Pi; typedef vector Vec; typedef vector Vi; typedef vector Vs; typedef vector Vc; typedef vector

VP; typedef vector VVP; typedef vector VV; typedef vector VVi; typedef vector VVc; typedef vector VVV; typedef vector VVVV; #define MAKEVV(variable, a, ...) VV variable(a, Vec(__VA_ARGS__)) #define MAKEVVc(variable, a, ...) VVc variable(a,Vc(__VA_ARGS__)) #define MAKEVVV(variable, a, b, ...) VVV variable(a, VV(b, Vec(__VA_ARGS__))) #define MAKEVVVV(variable, a, b, c, ...) VVVV variable(a, VVV(b, (VV(c, Vec(__VA_ARGS__))))) #define endl '\n' #define REP(i, a, b) for(ll i=(a); i<(b); i++) #define PER(i, a, b) for(ll i=(a); i>=(b); i--) #define rep(i, n) REP(i, 0, n) #define per(i, n) PER(i, n, 0) const ll INF = 4'000'000'000'000'000'010LL; const ll MOD=998244353; #define Yes(n) cout << ((n) ? "Yes" : "No") << endl; #define YES(n) cout << ((n) ? "YES" : "NO") << endl; #define ALL(v) v.begin(), v.end() #define rALL(v) v.rbegin(), v.rend() #define pb(x) push_back(x) #define mp(a, b) make_pair(a,b) #define Each(a,b) for(auto &a :b) #define rEach(i, mp) for (auto i = mp.rbegin(); i != mp.rend(); ++i) #define SUM(a) accumulate(ALL(a),0LL) #ifdef LOCAL #define dbg(x_) cerr << #x_ << ":" << x_ << endl; #define dbgmap(mp) cerr << #mp << ":"<first <<":"<second << endl;} #define dbgset(st) cerr << #st << ":"<bool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (bauto lb(T &X, ll x){return lower_bound(ALL(X),x) - X.begin();} templateauto ub(T &X, ll x){return upper_bound(ALL(X),x) - X.begin();} ll popcnt(ll x){return __builtin_popcount(x);} ll topbit(ll t){return t==0?-1:63-__builtin_clzll(t);} ll floor(ll y,ll x){assert(x != 0);if(x < 0){y *= -1; x *= -1;}if(y < 0){return (y-x+1)/x;}return y/x;}; ll ceil(ll y, ll x){assert(x != 0);if(x < 0){y *= -1; x *= -1;}if(y < 0){return y/x;}return (y+x-1)/x;}; template ostream &operator<<(ostream &s, const pair &p) { return s<<"("< istream &operator>>(istream &i, pair &p) { return i>>p.first>>p.second; } templateistream& operator>>(istream&i,vector&v) {rep(j,v.size())i>>v[j];return i;} // vector template ostream &operator<<(ostream &s, const vector &v) { int len=v.size(); for(int i=0; i ostream &operator<<(ostream &s, const vector > &vv) { s< divisor(ll n) { vector ret; for(ll i=1; i*i<=n; i++) { if(n%i==0) { ret.pb(i); if(i*i!=n) { ret.pb(n/i); } } } return ret; } vector> factorize(ll n) { vector> res; for (ll i = 2; i*i <= n; ++i) { if (n%i) continue; res.emplace_back(i,0); while (n%i == 0) { n /= i; res.back().second++; } } if (n != 1) res.emplace_back(n,1); return res; } int solve(){ ll n; cin>>n; Vec a(n); cin>>a; ll mx = *max_element(ALL(a)) + 3; Vec dp(mx); rep(i,n){ Vec div = divisor(a[i]); ll nx = 0; Each(e, div){ chmax(nx,dp[e] + 1); } chmax(dp[a[i]],nx); dbg(dp); } ll ans = 0; rep(i,mx){ chmax(ans,dp[i]); } out(ans); return 0; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); cout<>T; // while(T--) solve(); }