#include <bits/stdc++.h>
using namespace std;
bool cmp(pair<int, int> a, pair<int, int> b) {
  if (a.first != b.first)
    return a.first < b.first;
  else
    return a.second > b.second;
}
int main() {
  int t;
  int n;
  cin >> t;
  while (t--) {
    cin >> n;
    pair<int, int> ar[n];
    int bl[n + 1];
    for (int i = 0; i < n; i++) {
      cin >> ar[i].first;
      ar[i].second = i + 1;
      bl[i + 1] = 0;
    }
    sort(ar, ar + n, cmp);
    int xx, x;
    int ans = 0;
    for (int i = 0; i < n; i++) {
      x = ar[i].second;
      bl[x] = 1;
      xx = sqrt(x);
      if (x != 1) {
        for (int j = 1; j <= xx; j++) {
          if (x % j == 0) {
            bl[x] = max(bl[x], bl[j] + 1);
            if (j != 1) bl[x] = max(bl[x], bl[x / j] + 1);
          }
        }
      }
      if (ans < bl[x]) ans = bl[x];
    }
    cout << ans << endl;
  }
}
