#include <bits/stdc++.h>
using namespace std;
inline long long add(long long a, long long b) {
  a = (a + b);
  if (a >= 1000000007) a -= 1000000007;
  return a;
}
inline long long sub(long long a, long long b) {
  a = a - b;
  if (a < 0) a += 1000000007;
  return a;
}
inline long long mul(long long a, long long b) {
  a = (a * b) % 1000000007;
  return a;
}
const long long N = 1e6 + 5;
vector<long long> arr1(N, 0);
void pre() {
  for (long long i = 2; i < N; i++) {
    if (arr1[i] == 0) {
      for (long long j = i; j < N; j += i) {
        if (arr1[j] == 0) arr1[j] = i;
      }
    }
  }
}
void mymain() {
  long long n;
  cin >> n;
  vector<long long> arr(n);
  for (long long& i : arr) cin >> i;
  long long ans = 1;
  vector<long long> dp(n + 1, 1);
  for (long long i = 1; i <= n; i++) {
    for (long long j = 2; j * i <= n; j++) {
      long long k = j * i;
      if (arr[k - 1] > arr[i - 1]) {
        dp[k] = max(dp[k], dp[i] + 1);
      }
    }
  }
  for (long long i : dp) ans = max(i, ans);
  cout << ans << '\n';
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long t = 1;
  cin >> t;
  pre();
  for (long long tt = 0; tt < t; tt++) {
    mymain();
  }
  return 0;
}
