#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL), cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int a[n + 1];
    for (int i = 1; i <= n; i++) cin >> a[i];
    int f[n + 1], ans = INT_MIN;
    fill_n(f, n + 1, 1);
    for (int i = n; i >= 1; i--) {
      int maxx = 0;
      for (int j = 2 * i; j <= n; j += i) {
        if (a[j] > a[i]) {
          maxx = max(maxx, f[j]);
        }
      }
      f[i] = max(f[i], maxx + 1);
      ans = max(ans, f[i]);
    }
    cout << ans << "\n";
  }
  return 0;
}
