#include <bits/stdc++.h>
using namespace std;
long long const INF = 1e18;
long long const MOD = 998244353;
vector<long long> pr;
void solve() {
  long long n;
  cin >> n;
  vector<long long> s(n + 1), cnt(n + 1, 1);
  for (long long i = 1; i <= n; i++) {
    cin >> s[i];
  }
  for (long long i = 1; i <= n; ++i)
    for (long long j = i * 2; j <= n; j += i) {
      if (s[i] < s[j]) cnt[j] = max(cnt[j], cnt[i] + 1);
    }
  cout << *max_element(cnt.begin(), cnt.end());
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout.precision(16);
  long long t = 1;
  long long n = 1e6;
  vector<char> prime(n + 1, true);
  prime[0] = prime[1] = false;
  for (long long i = 2; i <= n; ++i)
    if (prime[i])
      if (i * 1ll * i <= n)
        for (long long j = i * i; j <= n; j += i) prime[j] = false;
  for (long long i = 0; i < n; i++) {
    if (prime[i]) {
      pr.push_back(i);
    }
  }
  cin >> t;
  while (t--) {
    solve();
    cout << endl;
  }
  return 0;
}
