//
//  main.cpp
//  2
//
//  Created by RISHAV SINGH MEHTA on 12/05/20.
//  Copyright © 2020 RISHAV SINGH MEHTA. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <math.h>
#define ll long long
using namespace std;
vector<ll int> fac;
ll int N;
vector<ll int> v;
ll int final_try(ll int n,ll int tv){
    ll int i,mx=tv,px;
    if ((n*2)>N) {
        //cout<<"he"<<endl;
       return tv;

    }
    for (i=n*2; i<=N; i=i+n) {
        if ((i)>N) {
            //cout<<"he"<<endl;
            return tv;

        }else{
            if (v[n]<=v[i]) {
                //cout<<"me"<<endl;
                mx=max(mx, final_try(i, tv+1));
            }
        }
    }
   // cout<<"ke"<<endl;
    return mx;
}
int main(int argc, const char * argv[]) {
    // insert code here...
    ll int i,j,k,l,T,M,a,b,c;
    cin>>T;
    while (T--) {
        cin>>N;
        v.clear();
        //vector<pair<ll int, ll int>> vp;
        v.push_back(0);
        for (i=0; i<N; i++) {
            cin>>a;
            v.push_back(a);
            //vp.push_back({a,i+1});
        }
        //sort(vp.begin(), vp.end());
        map<ll int, ll int > mp;
        /*for (i=N; i>=2; i++) {
            if ((N%i)>0) {
                fac.clear();
                printDivisors(i);
                if (v[i]<=v[i*2]) {
                    mp[i]+=1;
                    for (i=0; i<fac.size(); i++) {
                        mp[fac[i]]+=1;
                    }
                }
            }
        }*/
        /*
        //ll int ans=0,ist=1,num=v[1];
        for (i=1; i<=N; i++) {
            mp[vp[i].second]=i;
        }

        j=2;
        ll int ans=1,ta=0,pj=0,num=0;
        while ((N/j)>0) {
            ta=0;
            pj=j;
            num=v[j];
            for (i=mp[j]; i<=N; i++) {
                if ((num<=vp[i].first)&&(vp[i].second%pj==0)) {
                    num=vp[i].first;
                    ta+=1;
                    pj=vp[i].second;
                }

            }
            j+=1;
            ans=max(ans,ta);
         }*/ll int mx=0;
        for (i=1; i<=N; i++) {
            mx=max(mx, final_try(i,1));
        }
        cout<<mx<<endl;
    }
    return 0;
}
/*
 1
 20
 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
 */


//
//  main.cpp
//  2
//
//  Created by RISHAV SINGH MEHTA on 12/05/20.
//  Copyright © 2020 RISHAV SINGH MEHTA. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <math.h>
#define ll long long
using namespace std;
int main(int argc, const char * argv[]) {
    // insert code here...
    ll int i,j,k,l,N,T,M,a,b,c;
    cin>>T;
    while (T--) {
        cin>>N;
        vector<ll int> v;
        //vector<pair<ll int, ll int>> vp;
        v.push_back(0);
        for (i=0; i<N; i++) {
            cin>>a;
            v.push_back(a);
            //vp.push_back({a,i+1});
        }
        /*sort(vp.begin(), vp.end());
        ll int ans=0,ist=1,num=v[1];
        for (i=1; i<=N; i++) {
            if (vp[i].second==1) {
                ist=i;
                break;
            }
        }
        for (i=ist; i<=N; i++) {
            if (vp[i].first>=num) {
                ans+=1;
            }
        }*/
        j=1;
        ll int ans=1,ta=0,pj=0;
        while ((N/j)>0) {
            ta=1;
            pj=j;
            for (i=j*2; i<=N; i=i+j) {
                if (v[pj]<=v[i]) {
                    ta+=1;
                }else{
                    break;
                }
                pj=i;
            }
            if (v[1]<=v[j] && ta>1) {
                ta+=1;
            }
            j+=1;
            ans=max(ans,ta);
        }
        cout<<ans<<endl;
    }
    return 0;
}


//
//  main.cpp
//  2
//
//  Created by RISHAV SINGH MEHTA on 12/05/20.
//  Copyright © 2020 RISHAV SINGH MEHTA. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <math.h>
#define ll long long
using namespace std;
vector<ll int> fac;
ll int N;
void printDivisors(ll int n)
{
    // Note that this loop runs till square root
    for (ll int i=2; i<=sqrt(n); i++)
    {
        if (n%i == 0)
        {
            // If divisors are equal, print only one
            if (n/i == i){
                fac.push_back(i);}

            else{
                fac.push_back(i);fac.push_back(n/i);
            } // Otherwise print both
               // printf("%d %d ", i, n/i);
        }
    }
}vector<ll int> v;
ll int final_try(ll int n,ll int tv){
    ll int i,mx=tv;
    if ((n*2)>N) {
               //cout<<"he"<<endl;
               return tv;

           }
    for (i=n*2; i<=N; i=i+n) {
        if ((i)>N) {
            //cout<<"he"<<endl;
            return tv;

        }else{
            if (v[n]<=v[i]) {
                //cout<<"me"<<endl;
                mx=max(mx, final_try(i, tv+1));
            }
        }
    }
   // cout<<"ke"<<endl;
    return mx;
}
int main(int argc, const char * argv[]) {
    // insert code here...
    ll int i,j,k,l,T,M,a,b,c;
    cin>>T;
    while (T--) {
        cin>>N;
        v.clear();
        //vector<pair<ll int, ll int>> vp;
        v.push_back(0);
        for (i=0; i<N; i++) {
            cin>>a;
            v.push_back(a);
            //vp.push_back({a,i+1});
        }
        //sort(vp.begin(), vp.end());
        map<ll int, ll int > mp;
        /*for (i=N; i>=2; i++) {
            if ((N%i)>0) {
                fac.clear();
                printDivisors(i);
                if (v[i]<=v[i*2]) {
                    mp[i]+=1;
                    for (i=0; i<fac.size(); i++) {
                        mp[fac[i]]+=1;
                    }
                }
            }
        }*/
        /*
        //ll int ans=0,ist=1,num=v[1];
        for (i=1; i<=N; i++) {
            mp[vp[i].second]=i;
        }

        j=2;
        ll int ans=1,ta=0,pj=0,num=0;
        while ((N/j)>0) {
            ta=0;
            pj=j;
            num=v[j];
            for (i=mp[j]; i<=N; i++) {
                if ((num<=vp[i].first)&&(vp[i].second%pj==0)) {
                    num=vp[i].first;
                    ta+=1;
                    pj=vp[i].second;
                }

            }
            j+=1;
            ans=max(ans,ta);
        }*/
        cout<<final_try(1, 1)<<endl;
    }
    return 0;
}


//
//  main.cpp
//  2
//
//  Created by RISHAV SINGH MEHTA on 12/05/20.
//  Copyright © 2020 RISHAV SINGH MEHTA. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <math.h>
#define ll long long
using namespace std;
int main(int argc, const char * argv[]) {
    // insert code here...
    ll int i,j,k,l,N,T,M,a,b,c;
    cin>>T;
    while (T--) {
        cin>>N;
        vector<ll int> v;
        //vector<pair<ll int, ll int>> vp;
        v.push_back(0);
        for (i=0; i<N; i++) {
            cin>>a;
            v.push_back(a);
            //vp.push_back({a,i+1});
        }
        /*sort(vp.begin(), vp.end());
        ll int ans=0,ist=1,num=v[1];
        for (i=1; i<=N; i++) {
            if (vp[i].second==1) {
                ist=i;
                break;
            }
        }
        for (i=ist; i<=N; i++) {
            if (vp[i].first>=num) {
                ans+=1;
            }
        }*/
        j=2;
        ll int ans=1,ta=0,pj=0;
        while ((N/j)>0) {
            ta=1;
            pj=j;
            for (i=j*2; i<=N; i=i+j) {
                if (v[pj]<=v[i]) {
                    ta+=1;
                }else{
                    break;
                }
                pj=i;
            }
            if (v[1]<=v[j] && ta>1) {
                ta+=1;
            }
            j+=1;
            ans=max(ans,ta);
        }
        cout<<ans<<endl;
    }
    return 0;
}


//
//  main.cpp
//  2
//
//  Created by RISHAV SINGH MEHTA on 12/05/20.
//  Copyright © 2020 RISHAV SINGH MEHTA. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <math.h>
#define ll long long
using namespace std;
int main(int argc, const char * argv[]) {
    // insert code here...
    ll int i,j,k,l,N,T,M,a,b,c;
    cin>>T;
    while (T--) {
        cin>>N;
        vector<ll int> v;
        //vector<pair<ll int, ll int>> vp;
        v.push_back(0);
        for (i=0; i<N; i++) {
            cin>>a;
            v.push_back(a);
            //vp.push_back({a,i+1});
        }
        /*sort(vp.begin(), vp.end());
        ll int ans=0,ist=1,num=v[1];
        for (i=1; i<=N; i++) {
            if (vp[i].second==1) {
                ist=i;
                break;
            }
        }
        for (i=ist; i<=N; i++) {
            if (vp[i].first>=num) {
                ans+=1;
            }
        }*/
        j=2;
        ll int ans=1,ta=0,pj=0;
        while ((N/j)>0) {
            ta=1;
            pj=j;
            for (i=j*2; i<=N; i=i+j) {
                if (v[pj]<v[i]) {
                    ta+=1;
                }else{
                    break;
                }
                pj=i;
            }
            if (v[1]<v[j] && ta>1) {
                ta+=1;
            }
            j+=1;
            ans=max(ans,ta);
        }
        cout<<ans<<endl;
    }
    return 0;
}


//
//  main.cpp
//  2
//
//  Created by RISHAV SINGH MEHTA on 12/05/20.
//  Copyright © 2020 RISHAV SINGH MEHTA. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <math.h>
#define ll long long
using namespace std;
vector<ll int> fac;
ll int N;
vector<ll int> v;
ll int final_try(ll int n,ll int tv){
    ll int i,mx=tv;
    if ((n*2)>N) {
        //cout<<"he"<<endl;
       return tv;

    }
    for (i=n*2; i<=N; i=i+n) {
        if ((i)>N) {
            //cout<<"he"<<endl;
            return tv;

        }else{
            if (v[n]<v[i]) {
                //cout<<"me"<<endl;
                mx=max(mx, final_try(i, tv+1));
            }
        }
    }
   // cout<<"ke"<<endl;
    return mx;
}
int main(int argc, const char * argv[]) {
    // insert code here...
    ll int i,j,k,l,T,M,a,b,c;
    cin>>T;
    while (T--) {
        cin>>N;
        v.clear();
        //vector<pair<ll int, ll int>> vp;
        v.push_back(0);
        for (i=0; i<N; i++) {
            cin>>a;
            v.push_back(a);
            //vp.push_back({a,i+1});
        }
        //sort(vp.begin(), vp.end());
        map<ll int, ll int > mp;
        /*for (i=N; i>=2; i++) {
            if ((N%i)>0) {
                fac.clear();
                printDivisors(i);
                if (v[i]<=v[i*2]) {
                    mp[i]+=1;
                    for (i=0; i<fac.size(); i++) {
                        mp[fac[i]]+=1;
                    }
                }
            }
        }*/
        /*
        //ll int ans=0,ist=1,num=v[1];
        for (i=1; i<=N; i++) {
            mp[vp[i].second]=i;
        }

        j=2;
        ll int ans=1,ta=0,pj=0,num=0;
        while ((N/j)>0) {
            ta=0;
            pj=j;
            num=v[j];
            for (i=mp[j]; i<=N; i++) {
                if ((num<=vp[i].first)&&(vp[i].second%pj==0)) {
                    num=vp[i].first;
                    ta+=1;
                    pj=vp[i].second;
                }

            }
            j+=1;
            ans=max(ans,ta);
        }*/
        cout<<final_try(1, 1)<<endl;
    }
    return 0;
}


//
//  main.cpp
//  2
//
//  Created by RISHAV SINGH MEHTA on 12/05/20.
//  Copyright © 2020 RISHAV SINGH MEHTA. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <math.h>
#define ll long long
using namespace std;
int main(int argc, const char * argv[]) {
    // insert code here...
    ll int i,j,k,l,N,T,M,a,b,c;
    cin>>T;
    while (T--) {
        cin>>N;
        vector<ll int> v;
        vector<pair<ll int, ll int>> vp;
        v.push_back(0);
        for (i=0; i<N; i++) {
            cin>>a;
            v.push_back(a);
            vp.push_back({a,i+1});
        }
        sort(vp.begin(), vp.end());
        map<ll int, ll int > mp;

        //ll int ans=0,ist=1,num=v[1];
        for (i=1; i<=N; i++) {
            mp[vp[i].second]=i;
        }

        j=2;
        ll int ans=1,ta=0,pj=0,num=0;
        while ((N/j)>0) {
            ta=0;
            pj=j;num=v[j];
            for (i=mp[j]; i<=N; i++) {
                if ((num<=v[i])&&(vp[i].second%j==0)) {
                    num=vp[i].first;
                    ta+=1;
                }
                pj=i;
            }
            if (v[1]<=v[j]) {
                ta+=1;
            }
            j+=1;
            ans=max(ans,ta);
        }
        cout<<ans<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rip ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
vector <long long> vect(100100);
int main()
{
    for(long long int i=2;i<100010;i++)
    {
        if(vect[i]==0)
        {
            vect[i]=i;
            for(long long int j=i*i;j<100010;j+=i)
            {
                if(vect[j]==0)
                {
                    vect[j]=i;
                }
            }
        }
    }
    rip
    long long t;
    cin>>t;
    while(t--)
    {
        long long n,ans=1;
        cin>>n;
        vector <pair<long long,long long> > vect3;
        for(int i=0;i<n;i++)
        {
            long long a;
            cin>>a;
            vect3.push_back({a,i+1});
        }
        sort(vect3.begin(),vect3.end());
        vector <long long> vect2(n+5,1),visited(n+1);
        for(int i=n-1;i>=0;i--)
        {
            long long val=vect3[i].second,val2;
            val2=val;
            while(val>1)
            {
                if(visited[val2/vect[val]]==0)
                vect2[val2/vect[val]]=max(vect2[val2/vect[val]],vect2[val2]+1);
                long long b=vect[val];
                while(val%b==0)
                {
                    val/=b;
                }
            }
            visited[val2]=1;
        }
        long long fin=1;
        for(int i=1;i<=n;i++)
            fin=max(fin,vect2[i]);
        cout<<fin<<"\n";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rip ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main()
{
    rip
    long long t;
    cin>>t;
    while(t--)
    {
        long long n,max1=1;
        cin>>n;
        vector <long long> vect(n+1);
        for(int i=1;i<=n;i++)
            cin>>vect[i];
        deque <pair<long long,long long> > dq;
        dq.push_back({1,1});
        while(!dq.empty())
        {
            pair <long long,long long> p=dq.front();
            dq.pop_front();
            for(long long int i=2;i<=n;i++)
            {
                if(p.first*i>n)
                {
                    break;
                }
                else if(vect[p.first*i]>vect[p.first])
                {
                    dq.push_back({p.first*i,p.second+1});
                    max1=max(max1,p.second+1);
                }
            }
        }
        cout<<max1<<"\n";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rip ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main()
{
    rip
    long long t;
    cin>>t;
    while(t--)
    {
        long long n,max1=1;
        cin>>n;
        vector <long long> vect(n+1);
        for(int i=1;i<=n;i++)
            cin>>vect[i];
        deque <pair<long long,long long> > dq;
        for(int i=1;i<=n;i++)
        {
            dq.push_back({i,1});
            while(!dq.empty())
            {
                pair <long long,long long> p=dq.front();
                dq.pop_front();
                for(long long int i=2;i<=n;i++)
                {
                    if(p.first*i>n)
                    {
                        break;
                    }
                    else if(vect[p.first*i]>vect[p.first])
                    {
                        dq.push_back({p.first*i,p.second+1});
                        max1=max(max1,p.second+1);
                    }
                }
            }
            dq.clear();
        }
        cout<<max1<<"\n";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rip ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main()
{
    rip
    long long t;
    cin>>t;
    while(t--)
    {
        long long n,max1=1;
        cin>>n;
        vector <long long> vect(n+1);
        for(int i=1;i<=n;i++)
            cin>>vect[i];
        deque <pair<long long,long long> > dq;
        for(int i=1;i<=n;i++)
        {
            dq.push_back({i,1});
            while(!dq.empty())
            {
                pair <long long,long long> p=dq.front();
                dq.pop_front();
                for(long long int i=2;i<=n;i++)
                {
                    if(p.first*i>n)
                    {
                        break;
                    }
                    else if(vect[p.first*i]>vect[p.first])
                    {
                        dq.push_back({p.first*i,p.second+1});
                        max1=max(max1,p.second+1);
                    }
                }
            }
        }
        cout<<max1<<"\n";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rip ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
vector <long long> ans(100100),vect(100100);
long long n,max1=1;

long long fin(long long index)
{
    if(index>n)
        return 0;
    else if(ans[index]!=-1)
        return ans[index];
    else
    {
        long long val=1;
        for(long long int i=2;i*index<=n;i++)
        {
            if(vect[i*index]>vect[index])
            {
                val=max(val,1+fin(i*index));
            }
        }
        max1=max(max1,val);
        ans[index]=val;
        return val;
    }
}

int main()
{
    rip
    long long t;
    cin>>t;
    while(t--)
    {
        max1=1;
        cin>>n;
        for(int i=0;i<=n+2;i++)
            ans[i]=-1;
        for(int i=1;i<=n;i++)
            cin>>vect[i];
        fin(1);
        cout<<max1<<"\n";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rip ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
vector <long long> ans(100100),vect(100100);
long long n,max1=1;

long long fin(long long index)
{
    if(index>n)
        return 0;
    else if(ans[index]!=-1)
        return ans[index];
    else
    {
        long long val=1;
        for(long long int i=2;i*index<=n;i++)
        {
            if(vect[i*index]>vect[index])
            {
                val=max(val,1+fin(i*index));
            }
        }
        max1=max(max1,val);
        ans[index]=val;
        return val;
    }
}

int main()
{
    rip
    long long t;
    cin>>t;
    while(t--)
    {
        max1=1;
        cin>>n;
        for(int i=0;i<=n+2;i++)
            ans[i]=-1;
        for(int i=1;i<=n;i++)
            cin>>vect[i];
        cout<<max1<<"\n";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rip ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
vector <long long> ans(100100),vect(100100);
long long n;

long long fin(long long index)
{
    if(index>n)
        return 0;
    else if(ans[index]!=-1)
        return ans[index];
    else
    {
        long long val=1;
        for(long long int i=2;i*index<=n;i++)
        {
            if(vect[i*index]>vect[index])
            {
                val=max(val,1+fin(i*index));
            }
        }
        ans[index]=val;
        return val;
    }
}

int main()
{
    rip
    long long t;
    cin>>t;
    while(t--)
    {
        cin>>n;
        for(int i=0;i<=n+2;i++)
            ans[i]=-1;
        for(int i=1;i<=n;i++)
            cin>>vect[i];
        cout<<fin(1)<<"\n";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rip ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
vector <long long> ans(100100),vect(100100);
long long n,max1=1;

long long fin(long long index)
{
    if(ans[index]!=-1)
        return ans[index]-1;
    else
    {
        long long val=0,val2=1;
        for(long long int i=2;i*index<=n;i++)
        {
            if(vect[i*index]>vect[index])
            {
                val2=max(val2,2+fin(i*index));
                val=max(val,1+fin(i*index));
            }
            else
            {
                fin(i*index);
            }
        }
        max1=max(max1,val2);
        ans[index]=val2;
        return val;
    }
}

int main()
{
    rip
    long long t;
    cin>>t;
    while(t--)
    {
        max1=1;
        cin>>n;
        for(int i=0;i<=n+2;i++)
            ans[i]=-1;
        for(int i=1;i<=n;i++)
            cin>>vect[i];
        fin(1);
        cout<<max1<<"\n";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rip ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main()
{
    rip
    long long t;
    cin>>t;
    while(t--)
    {
        long long n,max1=1;
        cin>>n;
        vector <long long> vect(n+1);
        for(int i=1;i<=n;i++)
            cin>>vect[i];
        deque <pair<long long,long long> > dq;
        for(int i=1;i<=n;i++)
        dq.push_back({i,1});
        while(!dq.empty())
        {
            pair <long long,long long> p=dq.front();
            dq.pop_front();
            for(long long int i=2;i<=n;i++)
            {
                if(p.first*i>n)
                {
                    break;
                }
                else if(vect[p.first*i]>vect[p.first])
                {
                    dq.push_back({p.first*i,p.second+1});
                    max1=max(max1,p.second+1);
                }
            }
        }
        cout<<max1<<"\n";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rip ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main()
{
    rip
    long long t;
    cin>>t;
    while(t--)
    {
        long long n,max1=1;
        cin>>n;
        vector <long long> vect(n+1);
        for(int i=1;i<=n;i++)
            cin>>vect[i];
        deque <pair<long long,long long> > dq;
        for(int i=1;i<=n;i++)
        {
            dq.push_back({i,1});
            while(!dq.empty())
            {
                pair <long long,long long> p=dq.back();
                dq.pop_back();
                for(long long int i=2;i<=n;i++)
                {
                    if(p.first*i>n)
                    {
                        break;
                    }
                    else if(vect[p.first*i]>vect[p.first])
                    {
                        dq.push_back({p.first*i,p.second+1});
                        max1=max(max1,p.second+1);
                    }
                }
            }
            dq.clear();
        }
        cout<<max1<<"\n";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rip ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
vector <long long> ans(100100),vect(100100);
long long n;

long long fin(long long index)
{
    if(index>n)
        return 0;
    else if(ans[index]!=-1)
        return ans[index];
    else
    {
        long long val=1;
        for(long long int i=2;i<=n;i++)
        {
            if(vect[i*index]>vect[index])
            {
                val=max(val,1+fin(i*index));
            }
        }
        ans[index]=val;
        return val;
    }
}

int main()
{
    rip
    long long t;
    cin>>t;
    while(t--)
    {
        cin>>n;
        for(int i=0;i<=n+2;i++)
            ans[i]=-1;
        for(int i=1;i<=n;i++)
            cin>>vect[i];
        cout<<fin(1)<<"\n";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define E "\n"
#define int long long
#define f(i,l,n) for(int i=l;i<n;i++)

const int N=1e6+5;
int  spf[N];

void fu()
{
	spf[0]=spf[1]=1;
	f(i,2,N)
	{
		if(spf[i]==0);
		{
			for(int j=i;j<N;j+=i)
				{
					if(spf[j]==0) spf[j]=i;
				}
		}
	}
}

int solve()
{
	int n;
	cin >> n ;
	vector<pair<int,int>> a(n);
	for(int i=0;i<n;i++) cin >> a[i].first,a[i].second=i+1;

	sort(a.begin(),a.end());

	map<int,int> mp;

	int ans=1;

	f(i,0,n)
	{
		int ind=a[i].second;

			int t=ind,ter=10;
			//cout<<ind<<"-->\n";
			while(mp[t]==0 and t>1)
			{
				t=t/spf[t];
			//	cout<<t<<E;
			}

			mp[ind]=mp[t]+1;

		ans=max(ans,mp[ind]);
	}
	cout<<ans<<E;

	return 0;
}

int32_t main()
{

#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif
	fu();

	int t;
	cin >> t;
	while(t--)
	{
		solve();
	}
}


#include <bits/stdc++.h>
using namespace std;

#define E "\n"
#define int long long
#define f(i,l,n) for(int i=l;i<n;i++)

const int N=1e6+5;
int solve()
{
	int n;
	cin >> n ;
	vector<int> a(n+1);
	for(int i=1;i<=n;i++) cin >> a[i];

	int ans=1;
	int dp[n+1]={0};
	f(i,1,n+1)
	{
			dp[i]=1;
			for(int j=1;j*j<=i;j++)
			{
				if(i%j==0)
				{
					if(a[j]<a[i]) dp[i]=max(dp[i],dp[j]+1);
					if(a[i/j]<a[i]) dp[i]=max(dp[i],dp[i/j]+1);
				}
			}

			ans=max(ans,dp[i]);
	}

	cout<<ans<<E;

	return 0;
}

int32_t main()
{

#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif
	int t;
	cin >> t;
	while(t--)
	{
		solve();
	}
}


#include <bits/stdc++.h>
using namespace std;

#define E "\n"
#define int long long
#define f(i,l,n) for(int i=l;i<n;i++)

const int N=1e6+5;
int  spf[N];

void fu()
{
	spf[0]=spf[1]=1;
	f(i,2,N)
	{
		if(spf[i]==0);
		{
			for(int j=i;j<N;j+=i)
				{
					if(spf[j]==0) spf[j]=i;
				}
		}
	}
}

int solve()
{
	int n;
	cin >> n ;
	vector<pair<int,int>> a(n);
	for(int i=0;i<n;i++) cin >> a[i].first,a[i].second=i+1;

	//if(is_sorted(a.begin(),a.end())) return cout<<n<<E,0;
	//sort(a.begin(),a.end());

	map<int,int> mp;

	int ans=1;

	f(i,0,n)
	{
		int ind=i+1;

			int t=ind,cnt=0;
			//cout<<ind<<"-->\n";
			while(t>=1)
			{
				if(a[i].first>a[t-1].first) cnt=max(cnt,mp[t]+1);
				if(t==1) break;
				t=t/spf[t];
			//	cout<<t<<E;
			}
//			cout<<ind<<" "<<cnt<<E;

			mp[ind]=max(cnt,1LL);

		ans=max(ans,mp[ind]);
	}
	cout<<ans<<E;

	return 0;
}

int32_t main()
{

#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif
	fu();

	int t;
	cin >> t;
	while(t--)
	{
		solve();
	}
}


#include <bits/stdc++.h>
using namespace std;

#define E "\n"
#define int long long
#define f(i,l,n) for(int i=l;i<n;i++)

const int N=1e6+5;
int  spf[N];

void fu()
{
	spf[0]=spf[1]=1;
	f(i,2,N)
	{
		if(spf[i]==0);
		{
			for(int j=i;j<N;j+=i)
				{
					if(spf[j]==0) spf[j]=i;
				}
		}
	}
}

int solve()
{
	int n;
	cin >> n ;
	vector<pair<int,int>> a(n);
	for(int i=0;i<n;i++) cin >> a[i].first,a[i].second=i+1;

	//if(is_sorted(a.begin(),a.end())) return cout<<n<<E,0;
	//sort(a.begin(),a.end());

	map<int,int> mp;

	int ans=1;

	f(i,0,n)
	{
		int ind=i+1;

			int t=ind,cnt=0;
			//cout<<ind<<"-->\n";
			while(t>=1)
			{
				if(a[i].first>a[t-1].first) cnt=max(cnt,mp[t]+1);
				if(t==1) break;
				t=t/spf[t];
			//	cout<<t<<E;
			}
//			cout<<ind<<" "<<cnt<<E;

			mp[ind]=max(cnt,1LL);

		ans=max(ans,mp[ind]);
	}
	cout<<ans<<E;

	return 0;
}

int32_t main()
{

#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif
	f(i,0,N) spf[i]=0;
	fu();

	int t;
	cin >> t;
	while(t--)
	{
		solve();
	}
}


#include <bits/stdc++.h>
using namespace std;

#define E "\n"
#define int long long
#define f(i,l,n) for(int i=l;i<n;i++)

const int N=1e6+5;
int  spf[N];

void fu()
{
	spf[0]=spf[1]=1;
	f(i,2,N)
	{
		if(spf[i]==0);
		{
			for(int j=i;j<N;j+=i)
				{
					if(spf[j]==0) spf[j]=i;
				}
		}
	}
}

int solve()
{
	int n;
	cin >> n ;
	vector<int> a(n+1);
	for(int i=1;i<=n;i++) cin >> a[i];

	map<int,int> mp;
	int ans=1;

	f(i,1,n+1)
	{
			int ind=i;
			int t=ind,cnt=0;
			while(t>=1)
			{
				if(a[i]>a[t]) cnt=max(cnt,mp[t]+1);
				if(t==1) break;
				t=t/spf[t];
			//	cout<<t<<E;
			}
		//	cout<<ind<<" "<<cnt<<E;
			mp[ind]=max(cnt,1LL);

		ans=max(ans,mp[ind]);
	}
	cout<<ans<<E;

	return 0;
}

int32_t main()
{

#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif
	f(i,0,N) spf[i]=0;
	fu();

	int t;
	cin >> t;
	while(t--)
	{
		solve();
	}
}


#include <bits/stdc++.h>
using namespace std;

#define E "\n"
#define int long long
#define f(i,l,n) for(int i=l;i<n;i++)

const int N=1e6+5;
int  spf[N];

void fu()
{
	spf[0]=spf[1]=1;
	f(i,2,N)
	{
		if(spf[i]==0);
		{
			for(int j=i;j<N;j+=i)
				{
					if(spf[j]==0) spf[j]=i;
				}
		}
	}
}

int solve()
{
	int n;
	cin >> n ;
	vector<int> a(n+1);
	for(int i=1;i<=n;i++) cin >> a[i];

	map<int,int> mp;
	int ans=1;
	a[0]=1e18;
	f(i,1,n+1)
	{
			int ind=i;
			int t=ind,cnt=0,temp=0;
			while(t>=1)
			{
				if(a[i]>a[t]) cnt=max(cnt,mp[t]+1);
				if(a[i]>a[temp]) cnt=max(cnt,mp[temp]+1);
				if(t==1) break;
				if(temp==0) temp=1;
					temp=temp*spf[t];
				t=t/spf[t];

			//	cout<<t<<E;
			}
			//cout<<ind<<" "<<cnt<<E;
			mp[ind]=max(cnt,1LL);

		ans=max(ans,mp[ind]);
	}
	cout<<ans<<E;

	return 0;
}

int32_t main()
{

#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif
	f(i,0,N) spf[i]=0;
	fu();

	int t;
	cin >> t;
	while(t--)
	{
		solve();
	}
}


#include <bits/stdc++.h>
using namespace std;

#define E "\n"
#define int long long
#define f(i,l,n) for(int i=l;i<n;i++)

const int N=1e6+5;
int  spf[N];

void fu()
{
	spf[0]=spf[1]=1;
	f(i,2,N)
	{
		if(spf[i]==0);
		{
			for(int j=i;j<N;j+=i)
				{
					if(spf[j]==0) spf[j]=i;
				}
		}
	}
}

int solve()
{
	int n;
	cin >> n ;
	vector<pair<int,int>> a(n);
	for(int i=0;i<n;i++) cin >> a[i].first,a[i].second=i+1;

	sort(a.begin(),a.end());

	map<int,int> mp;

	int ans=1;

	f(i,0,n)
	{
		int ind=a[i].second;
		if(spf[ind]==ind)
		{
			mp[ind]=1;
		}
		else
		{
			int t=ind,ter=10;
			//cout<<ind<<"-->\n";
			while(mp[t]==0 and t>1)
			{
				t=t/spf[t];
			//	cout<<t<<E;
			}
			mp[ind]=mp[t]+1;
		}
		ans=max(ans,mp[ind]);
	}
	cout<<ans<<E;

	return 0;
}

int32_t main()
{

#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif
	fu();

	int t;
	cin >> t;
	while(t--)
	{
		solve();
	}
}


#include <bits/stdc++.h>
using namespace std;

#define E "\n"
#define int long long
#define f(i,l,n) for(int i=l;i<n;i++)

const int N=1e6+5;
int  spf[N];

void fu()
{
	spf[0]=spf[1]=1;
	f(i,2,N)
	{
		if(spf[i]==0);
		{
			for(int j=i;j<N;j+=i)
				{
					if(spf[j]==0) spf[j]=i;
				}
		}
	}
}

int solve()
{
	int n;
	cin >> n ;
	vector<int> a(n+1);
	for(int i=1;i<=n;i++) cin >> a[i];

	map<int,int> mp;
	int ans=1;
	a[0]=1e18;
	f(i,1,n+1)
	{
			int ind=i;
			int t=ind,cnt=0;
			while(t>=1)
			{
				if(a[i]>a[t]) cnt=max(cnt,mp[t]+1);
				if(a[i]>a[spf[t]]) cnt=max(cnt,mp[spf[t]]+1);
				if(t==1) break;
				t=t/spf[t];

			//	cout<<t<<E;
			}
			//cout<<ind<<" "<<cnt<<E;
			mp[ind]=max(cnt,1LL);

		ans=max(ans,mp[ind]);
	}
	cout<<ans<<E;

	return 0;
}

int32_t main()
{

#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif
	f(i,0,N) spf[i]=0;
	fu();

	int t;
	cin >> t;
	while(t--)
	{
		solve();
	}
}


#include <bits/stdc++.h>
using namespace std;

#define E "\n"
#define int long long
#define f(i,l,n) for(int i=l;i<n;i++)

const int N=1e6+5;
int  spf[N];

void fu()
{
	spf[0]=spf[1]=1;
	f(i,2,N)
	{
		if(spf[i]==0);
		{
			for(int j=i;j<N;j+=i)
				{
					if(spf[j]==0) spf[j]=i;
				}
		}
	}
}

int solve()
{
	int n;
	cin >> n ;
	vector<pair<int,int>> a(n);
	for(int i=0;i<n;i++) cin >> a[i].first,a[i].second=i+1;

	//if(is_sorted(a.begin(),a.end())) return cout<<n<<E,0;
	sort(a.begin(),a.end());

	map<int,int> mp;

	int ans=1;

	f(i,0,n)
	{
		int ind=a[i].second;

			int t=ind,cnt=0;
			//cout<<ind<<"-->\n";
			while(t>=1)
			{
				cnt=max(cnt,mp[t]+1);
				if(t==1) break;
				t=t/spf[t];
			//	cout<<t<<E;
			}
			//cout<<ind<<" "<<cnt<<E;

			mp[ind]=cnt;

		ans=max(ans,mp[ind]);
	}
	cout<<ans<<E;

	return 0;
}

int32_t main()
{

#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif
	fu();

	int t;
	cin >> t;
	while(t--)
	{
		solve();
	}
}


#include <bits/stdc++.h>
using namespace std;

#define E "\n"
#define int long long
#define f(i,l,n) for(int i=l;i<n;i++)

const int N=1e6+5;
int  spf[N];

void fu()
{
	spf[0]=spf[1]=1;
	f(i,2,N)
	{
		if(spf[i]==0);
		{
			for(int j=i;j<N;j+=i)
				{
					if(spf[j]==0) spf[j]=i;
				}
		}
	}
}

int solve()
{
	int n;
	cin >> n ;
	vector<int> a(n+1);
	for(int i=1;i<=n;i++) cin >> a[i];

	map<int,int> mp;
	int ans=1;
	int dp[n+1]={0};
	f(i,1,n+1)
	{
			dp[i]=1;
			for(int j=1;j*j<=i;j++)
			{
				if(i%j==0)
				{
					if(a[j]<a[i]) dp[i]=max(dp[i],dp[j]+1);
					if(a[i/j]<a[i]) dp[i]=max(dp[i],dp[i/j]);
				}
			}

			ans=max(ans,dp[i]);
	}

	cout<<ans<<E;

	return 0;
}

int32_t main()
{

#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif
	f(i,0,N) spf[i]=0;
	fu();

	int t;
	cin >> t;
	while(t--)
	{
		solve();
	}
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 100000000
#define MAXN 1000005

void solve() {
    int n;
    cin>>n;
    int a[n];
    for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	int ans=1;
	for (int i = 2; i <= n; i++) {
		int c=1,prev=a[i];
		if(a[i]>a[1])c++;
		for(int j=i*2;j<=n;j+=i){
			if(a[j]>prev){
				prev=a[j];
				c++;
			}
		}
		ans=max(ans,c);
	}
	cout<<ans<<endl;
}
int32_t main() {
	int t=1;
	cin>>t;
	while(t--){
		// cout<<"Case"<<t<<endl;
		solve();
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 100000000
#define MAXN 100005
int CeilIndex(vector<int>& v, int l, int r, int key)
{
    while (r - l > 1) {
        int m = l + (r - l) / 2;
        if (v[m] >= key)
            r = m;
        else
            l = m;
    }

    return r;
}

int LongestIncreasingSubsequenceLength(vector<int>& v)
{
    if (v.size() == 0)
        return 0;

    vector<int> tail(v.size(), 0);
    int length = 1; // always points empty slot in tail

    tail[0] = v[0];
    for (size_t i = 1; i < v.size(); i++) {

        // new smallest value
        if (v[i] < tail[0])
            tail[0] = v[i];

        // v[i] extends largest subsequence
        else if (v[i] > tail[length - 1])
            tail[length++] = v[i];

        // v[i] will become end candidate of an existing
        // subsequence or Throw away larger elements in all
        // LIS, to make room for upcoming grater elements
        // than v[i] (and also, v[i] would have already
        // appeared in one of LIS, identify the location
        // and replace it)
        else
            tail[CeilIndex(tail, -1, length - 1, v[i])] = v[i];
    }

    return length;
}
void solve() {
    int n;
    cin>>n;
    int a[MAXN];
    for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	int ans=1;
	for (int i : {2,3,5,7,11,13}) {
		vector<int> v;
		v.push_back(a[1]);
		for(int j=i;j<=n;j+=i){
			v.push_back(a[j]);
		}
		int c=LongestIncreasingSubsequenceLength(v);
		v.clear();
		ans=max(ans,c);
	}
	cout<<ans<<endl;
}
int32_t main() {
	int t=1;
	cin>>t;
	while(t--){
		// cout<<"Case"<<t<<endl;
		solve();
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 100000000
#define MAXN 100005
int lis(vector<int> &arr)
{
    int i,N=arr.size();
    set<int> s;
    set<int>::iterator k;
    for (i=0; i<N; i++)
    {

        if (s.insert(arr[i]).second)
        {
            // Find the position of inserted element in iterator k
            k = s.find(arr[i]);

            k++;  // Find the next greater element in set

            if (k!=s.end()) s.erase(k);
        }
    }

    return s.size();
}
void solve() {
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int ans=1;
	for (int i : {2,3,5,7,11,13}) {
		vector<int> v;
		v.push_back(a[0]);
		for(int j=i-1;j<n;j+=i){
			v.push_back(a[j]);
		}
		int c=lis(v);
		ans=max(ans,c);
	}
	cout<<ans<<endl;
}
int32_t main() {
	int t=1;
	cin>>t;
	while(t--){
		// cout<<"Case"<<t<<endl;
		solve();
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 100000000
#define MAXN 1000005

void solve() {
    int n;
    cin>>n;
    int a[n];
    for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	int ans=1;
	vector<char> is_prime(n+1, true);
	is_prime[0] = is_prime[1] = false;
	for (int i = 2; i <= n; i++) {
		if (is_prime[i]) {
			int c=1;
			if(a[i]>a[1])c++;
			int prev=a[i];
			for (int j = i * 2; j <= n; j += i){
				if(a[j]>prev){
					//~ cout<<i<<" "<<j<<endl;
					prev=a[j];
					c++;
					is_prime[j] = false;
				}
			}
			ans=max(ans,c);
		}

	}
	cout<<ans<<endl;
}
int32_t main() {
	int t=1;
	cin>>t;
	while(t--){
		// cout<<"Case"<<t<<endl;
		solve();
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 100000000
#define MAXN 100005
int CeilIndex(vector<int>& v, int l, int r, int key)
{
    while (r - l > 1) {
        int m = l + (r - l) / 2;
        if (v[m] >= key)
            r = m;
        else
            l = m;
    }

    return r;
}

int LongestIncreasingSubsequenceLength(vector<int>& v)
{
    if (v.size() == 0)
        return 0;

    vector<int> tail(v.size(), 0);
    int length = 1; // always points empty slot in tail

    tail[0] = v[0];
    for (size_t i = 1; i < v.size(); i++) {

        if (v[i] < tail[0])
            tail[0] = v[i];

        else if (v[i] > tail[length - 1])
            tail[length++] = v[i];

        else
            tail[CeilIndex(tail, -1, length - 1, v[i])] = v[i];
    }

    return length;
}
void solve() {
    int n;
    cin>>n;
    int a[MAXN];
    for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	int ans=1;
	for (int i : {2,3,5,7,11,13,17,23,29,31,37,41,43,47}) {
		vector<int> v;
		v.push_back(a[1]);
		for(int j=i;j<=n;j+=i){
			v.push_back(a[j]);
		}
		int c=LongestIncreasingSubsequenceLength(v);
		v.clear();
		ans=max(ans,c);
	}
	cout<<ans<<endl;
}
int32_t main() {
	int t=1;
	cin>>t;
	while(t--){
		// cout<<"Case"<<t<<endl;
		solve();
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 100000000
#define MAXN 100005
void solve() {
    int n;
    cin>>n;
    int a[n],dp[n+10];
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	int ans=1;
	for(int i=1;i<=n;i++){
	    dp[i]=max(1LL,dp[i]);
	    for(int j=i*2;j<=n;j+=i){
	        if(a[j]>a[i]){
	            dp[j]=max(dp[j],dp[i]+1);
	        }
	    }
	    ans=max(ans,dp[i]);
	}
	cout<<ans<<endl;
}
int32_t main() {
	int t=1;
	cin>>t;
	while(t--){
		// cout<<"Case"<<t<<endl;
		solve();
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 100000000
#define MAXN 100005
int lis(vector<int> &arr)
{
    int i,N=arr.size();
    set<int> s;
    set<int>::iterator k;
    for (i=0; i<N; i++)
    {
        // Check if the element was actually inserted
        // An element in set is not inserted if it is
        // already present. Please see
        // https://www.geeksforgeeks.org/set-insert-function-in-c-stl/
        if (s.insert(arr[i]).second)
        {
            // Find the position of inserted element in iterator k
            k = s.find(arr[i]);

            k++;  // Find the next greater element in set

            // If the new element is not inserted at the end, then
            // remove the greater element next to it (This is tricky)
            if (k!=s.end()) s.erase(k);
        }
    }

    // Note that set s may not contain actual LIS, but its size gives
    // us the length of LIS
    return s.size();
}
void solve() {
    int n;
    cin>>n;
    int a[MAXN];
    for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	int ans=1;
	for (int i : {2,3,5,7,11,13}) {
		vector<int> v;
		v.push_back(a[1]);
		for(int j=i;j<=n;j+=i){
			v.push_back(a[j]);
		}
		int c=lis(v);
		v.clear();
		ans=max(ans,c);
	}
	cout<<ans<<endl;
}
int32_t main() {
	int t=1;
	cin>>t;
	while(t--){
		// cout<<"Case"<<t<<endl;
		solve();
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 100000000
#define MAXN 100005

void solve() {
    int n;
    cin>>n;
    int a[MAXN];
    for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	int ans=1;
	for (int i = 2; i <= n; i++) {
		int c=1,prev=a[i];
		if(a[i]>a[1])c++;
		for(int j=i*2;j<=n;j+=i){
			if(a[j]>prev){
				prev=a[j];
				c++;
			}
		}
		ans=max(ans,c);
	}
	cout<<ans<<endl;
}
int32_t main() {
	int t=1;
	cin>>t;
	while(t--){
		// cout<<"Case"<<t<<endl;
		solve();
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 100000000
#define MAXN 100005
int LongestIncreasingSubsequenceLength(vector<int>& v)
{
    if (v.size() == 0)
        return 0;

    std::vector<int> tail(v.size(), 0);
    int length = 1; // always points empty slot in tail

    tail[0] = v[0];

    for (int i = 1; i < v.size(); i++) {

            // Do binary search for the element in
            // the range from begin to begin + length
        auto b = tail.begin(), e = tail.begin() + length;
        auto it = lower_bound(b, e, v[i]);

        // If not present change the tail element to v[i]
        if (it == tail.begin() + length)
        tail[length++] = v[i];
        else
        *it = v[i];
    }

    return length;
}
void solve() {
    int n;
    cin>>n;
    int a[MAXN];
    for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	int ans=1;
	for (int i : {2,3,5,7,11,13}) {
		vector<int> v;
		v.push_back(a[1]);
		for(int j=i;j<=n;j+=i){
			v.push_back(a[j]);
		}
		int c=LongestIncreasingSubsequenceLength(v);
		v.clear();
		ans=max(ans,c);
	}
	cout<<ans<<endl;
}
int32_t main() {
	int t=1;
	cin>>t;
	while(t--){
		// cout<<"Case"<<t<<endl;
		solve();
	}
	return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(c)  c.begin(), c.end()
#define llv vector< ll >
#define mp make_pair
#define endl "\n"
#define N (ll)1e5+10
//#define M (ll)1e9+7
#define matrix vector<vector<ll> >

ll lp[N] = {0} ;
void sieve(ll n){
    for(ll i=2 ; i<=n ; i++){
       if(lp[i])continue ;
       for(ll j=i ; j<=n ; j+=i){
            lp[j]=i ;
       }
    }
}
int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios::sync_with_stdio(0);

    sieve(N) ;
    ll t ;
    cin >> t ;
    while(t--){
        ll n , i ;
        cin >> n ;
        ll a[n+1] , max_len[n+1] ;
        for(i=1 ; i<=n ; i++){
               cin >> a[i] ;
        }
        max_len[1]=1 ;
        for(i=2 ; i<=n ; i++){
               max_len[i] = 1 ;

               if(lp[i]==i){
                  if(a[i]>a[1])max_len[i]=2 ;
                  continue ;
               }
               ll temp = i ;
               while(temp>1){
                    ll j = lp[temp] ;
                    if(a[j]<a[i])max_len[i] = max(max_len[i] , 1+ max_len[j]) ;
                    while(temp%j==0){temp = temp/j ;}
               }
        }
        ll ethan = 1 ;
        for(i=1 ; i<=n ; i++){
              ethan = max(ethan , max_len[i]) ;
        }

        cout << ethan << endl ;
    }

    return 0 ;

}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(c)  c.begin(), c.end()
#define llv vector< ll >
#define mp make_pair
#define endl "\n"
#define N (ll)1e5+10
//#define M (ll)1e9+7
#define matrix vector<vector<ll> >

int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios::sync_with_stdio(0);

    ll t ;
    cin >> t ;
    while(t--){
        ll n , i , j  ;
        cin >> n ;
        ll a[n+1] , max_len[n+1] ;
        for(i=1 ; i<=n ; i++){
               cin >> a[i] ;
               max_len[i]=1 ;
        }

        for(i=2 ; i<=n ; i++){
               set<ll>s ;
               for(j=1 ; j*j <=i ; j++){
                   if(i%j==0){
                     s.insert(j) ;
                     if(j>1) s.insert(i/j) ;
                   }
               }
               for(auto e:s){
                  if(a[e]<=a[i])max_len[i] = max(max_len[i] , 1+ max_len[e]) ;
               }

        }
        ll ethan = 1 ;
        for(i=1 ; i<=n ; i++){
              //cout << max_len[i] << endl ;
              ethan = max(ethan , max_len[i]) ;
        }

        cout << ethan << endl ;
    }

    return 0 ;

}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(c)  c.begin(), c.end()
#define llv vector< ll >
#define mp make_pair
#define endl "\n"
#define N (ll)1e5+10
//#define M (ll)1e9+7
#define matrix vector<vector<ll> >

int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios::sync_with_stdio(0);

    ll t ;
    cin >> t ;
    while(t--){
        ll n , i , j  ;
        cin >> n ;
        ll a[n+1] , max_len[n+1] ;
        for(i=1 ; i<=n ; i++){
               cin >> a[i] ;
               max_len[i]=0 ;
        }

        for(i=1 ; i<=n ; i++){
               set<ll>s ;
               for(j=1 ; j*j <=i ; j++){
                   if(i%j==0){
                      s.insert(j) ;
                     if(j>1) s.insert(i/j) ;
                   }
               }
               for(auto e:s){
                  if(a[e]<=a[i])max_len[i] = max(max_len[i] , 1+ max_len[e]) ;
               }
        }
        ll ethan = 1 ;
        for(i=1 ; i<=n ; i++){
              cout << max_len[i] << endl ;
              ethan = max(ethan , max_len[i]) ;
        }

        cout << ethan << endl ;
    }

    return 0 ;

}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(c)  c.begin(), c.end()
#define llv vector< ll >
#define mp make_pair
#define endl "\n"
#define N (ll)1e5+10
//#define M (ll)1e9+7
#define matrix vector<vector<ll> >

int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios::sync_with_stdio(0);

    ll t ;
    cin >> t ;
    while(t--){
        ll n , i , j  ;
        cin >> n ;
        ll a[n+1] , max_len[n+1] ;
        for(i=1 ; i<=n ; i++){
               cin >> a[i] ;
               max_len[i]=1 ;
        }

        for(i=2 ; i<=n ; i++){
               set<ll>s ;
               s.insert(1) ;
               for(j=2 ; j*j <=i ; j++){
                   if(i%j==0){
                     s.insert(j) ;
                     s.insert(i/j) ;
                   }
               }
               for(auto e:s){
                  if(a[e]<a[i])max_len[i] = max(max_len[i] , 1+ max_len[e]) ;
               }

        }
        ll ethan = 1 ;
        for(i=1 ; i<=n ; i++){
              //cout << max_len[i] << endl ;
              ethan = max(ethan , max_len[i]) ;
        }

        cout << ethan << endl ;
    }

    return 0 ;

}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(c)  c.begin(), c.end()
#define llv vector< ll >
#define mp make_pair
#define endl "\n"
#define N (ll)1e5+10
//#define M (ll)1e9+7
#define matrix vector<vector<ll> >

int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios::sync_with_stdio(0);

    ll t ;
    cin >> t ;
    while(t--){
        ll n , i , j  ;
        cin >> n ;
        ll a[n+1] , max_len[n+1] ;
        for(i=1 ; i<=n ; i++){
               cin >> a[i] ;
               max_len[i]=0 ;
        }

        for(i=1 ; i<=n ; i++){
               set<ll>s ;
               for(j=1 ; j*j <=i ; j++){
                   if(i%j==0){
                      s.insert(j) ;
                     if(j>1) s.insert(i/j) ;
                   }
               }
               for(auto e:s){
                  if(a[e]<=a[i])max_len[i] = max(max_len[i] , 1+ max_len[e]) ;
               }
        }
        ll ethan = 1 ;
        for(i=1 ; i<=n ; i++){
              //cout << max_len[i] << endl ;
              ethan = max(ethan , max_len[i]) ;
        }

        cout << ethan << endl ;
    }

    return 0 ;

}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(c)  c.begin(), c.end()
#define llv vector< ll >
#define mp make_pair
#define endl "\n"
#define N (ll)1e3+10
//#define M (ll)1e9+7
#define matrix vector<vector<ll> >

ll lp[N] = {0} ;
void sieve(ll n){
    for(ll i=2 ; i<=n ; i++){
       if(lp[i])continue ;
       for(ll j=i ; j<=n ; j+=i){
            lp[j]=i ;
       }
    }
}
int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios::sync_with_stdio(0);

    sieve(N) ;
    ll t ;
    cin >> t ;
    while(t--){
        ll n , i ;
        cin >> n ;
        ll a[n+1] , max_len[n+1] ;
        for(i=1 ; i<=n ; i++){
               cin >> a[i] ;
        }
        max_len[1]=1 ;
        for(i=2 ; i<=n ; i++){
               max_len[i] = 1 ;
               ll temp = i ;
               if(lp[i]==i){
                  if(a[i]>=a[1])max_len[i]=2 ;
                  continue ;
               }

               while(temp>1){
                    ll j = lp[temp] ;
                    if(j!=i && a[j]<=a[i])max_len[i] = max(max_len[i] , 1+ max_len[j]) ;

                    while(temp%j==0){temp = temp/j ;}
               }
        }
        ll ethan = 1 ;
        for(i=1 ; i<=n ; i++){
              ethan = max(ethan , max_len[i]) ;
        }

        cout << ethan << endl ;
    }

    return 0 ;

}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(c)  c.begin(), c.end()
#define llv vector< ll >
#define mp make_pair
#define endl "\n"
#define N (ll)1e5+10
//#define M (ll)1e9+7
#define matrix vector<vector<ll> >

int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios::sync_with_stdio(0);

    ll t ;
    cin >> t ;
    while(t--){
        ll n , i , j  ;
        cin >> n ;
        ll a[n+1] , max_len[n+1] ;
        for(i=1 ; i<=n ; i++){
               cin >> a[i] ;
               max_len[i]=1 ;
        }

        for(i=1 ; i<=n ; i++){
               set<ll>s ;
               for(j=1 ; j*j <=i ; j++){
                   if(i%j==0){
                    if(i!=j)  s.insert(j) ;
                     if(j>1) s.insert(i/j) ;
                   }
               }
               for(auto e:s){
                  if(a[e]<=a[i])max_len[i] = max(max_len[i] , 1+ max_len[e]) ;
               }

        }
        ll ethan = 1 ;
        for(i=1 ; i<=n ; i++){
              //cout << max_len[i] << endl ;
              ethan = max(ethan , max_len[i]) ;
        }

        cout << ethan << endl ;
    }

    return 0 ;

}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(c)  c.begin(), c.end()
#define llv vector< ll >
#define mp make_pair
#define endl "\n"
#define N (ll)1e5+10
//#define M (ll)1e9+7
#define matrix vector<vector<ll> >

ll lp[N] = {0} ;
void sieve(ll n){
    for(ll i=2 ; i<=n ; i++){
       if(lp[i])continue ;
       for(ll j=i ; j<=n ; j+=i){
            lp[j]=i ;
       }
    }
}
int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios::sync_with_stdio(0);

    sieve(N) ;
    ll t ;
    cin >> t ;
    while(t--){
        ll n , i ;
        cin >> n ;
        ll a[n+1] , max_len[n+1] ;
        for(i=1 ; i<=n ; i++){
               cin >> a[i] ;
        }
        max_len[1]=1 ;
        for(i=2 ; i<=n ; i++){
               max_len[i] = 1 ;
               ll temp = i ;
               if(lp[i]==i){
                  if(a[i]>=a[1])max_len[i]=2 ;
                  continue ;
               }

               while(temp>1){
                    ll j = lp[temp] ;
                    if(j!=i && a[j]<=a[i])max_len[i] = max(max_len[i] , 1+ max_len[j]) ;

                    while(temp%j==0){temp = temp/j ;}
               }
        }
        ll ethan = 1 ;
        for(i=1 ; i<=n ; i++){
              ethan = max(ethan , max_len[i]) ;
        }

        cout << ethan << endl ;
    }

    return 0 ;

}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(c)  c.begin(), c.end()
#define llv vector< ll >
#define mp make_pair
#define endl "\n"
#define N (ll)1e5+10
//#define M (ll)1e9+7
#define matrix vector<vector<ll> >

ll lp[N] = {0} ;
void sieve(ll n){
    for(ll i=2 ; i<=n ; i++){
       if(lp[i])continue ;
       for(ll j=i ; j<=n ; j+=i){
            lp[j]=i ;
       }
    }
}
int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios::sync_with_stdio(0);

    sieve(N) ;
    ll t ;
    cin >> t ;
    while(t--){
        ll n , i ;
        cin >> n ;
        ll a[n+1] , max_len[n+1] ;
        for(i=1 ; i<=n ; i++){
               cin >> a[i] ;
        }
        max_len[1]=1 ;
        for(i=2 ; i<=n ; i++){
               max_len[i] = 1 ;

               if(lp[i]==i){
                  if(a[i]>=a[1])max_len[i]=2 ;
                  continue ;
               }
               ll temp = i ;
               while(temp>1){
                    ll j = lp[temp] ;
                    if(a[j]<=a[i])max_len[i] = max(max_len[i] , 1+ max_len[j]) ;
                    temp = temp/j ;
               }
        }
        ll ethan = 1 ;
        for(i=1 ; i<=n ; i++){
              ethan = max(ethan , max_len[i]) ;
        }

        cout << ethan << endl ;
    }

    return 0 ;

}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(c)  c.begin(), c.end()
#define llv vector< ll >
#define mp make_pair
#define endl "\n"
#define N (ll)1e5+10
//#define M (ll)1e9+7
#define matrix vector<vector<ll> >

int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios::sync_with_stdio(0);
    ll t ;
    cin >> t ;
    while(t--){
      ll n , i , j  ;
      cin >> n ;
      ll s[n+1] ;
      bool mark[n+1] ;
      for(i=1 ; i<=n ; i++){
           cin >> s[i] ;
           mark[i]=0;
      }
      if(n==1){
          cout << 1 << endl ;
          continue ;
      }
      ll ethan = 0 ;
      for(i=2 ; i<=n ; i++){
           if(mark[i])continue ;
           vector<pair<ll , ll > > v ;
           for(j =i ; j<=n ; j+=i){
               mark[j]=1 ;
                 v.pb(mp(s[j] , j )) ;
           }
           v.pb(mp(s[1] , 1)) ;
          sort(all(v)) ;
          ll idx=v[0].S  , len=1  ;
         for(j=1 ; j<v.size() ; j++){
              if(v[j].S>idx){
                   len++ ;
                   idx = v[j].S ;
              }else idx = v[j].S ;
         }
         ethan  = max(ethan , len) ;
      }

      cout << ethan << endl ;
    }
    return 0 ;

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        int a[n+1],b[n+1]={0},i,j,x,y;
        for(i=1;i<=n;i++)
        {
            cin>>a[i];
            b[i]=1;
        }
        for(i=n/2;i>1;i--)
        {
            if(a[i+i]>a[i])
                b[i]=b[i+i]+1;
        }
        for(i=2;i<=n;i++)
        {
            if(a[i]>a[1])
                b[i]++;
        }
        sort(b,b+n+1);
        cout<<b[n]<<endl;
    }return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        int i,a[n+1],j,x,y=1,s,l,c=0;;
        for(i=1;i<=n;i++)
            cin>>a[i];
        for(i=1;i<=n/2;i++)
        {
            if(a[i]==1&&i==1)
            {
                i++;
                c=1;
            }
            s=1;
            x=a[i];
            l=i;
            for(j=i+i;j<=n;j+=l)
            {
                if(a[j]>x)
                {
                    s++;
                    x=a[j];
                    l=j;
                }
            }
            if(y<s)
                y=s;
        }
        if(c==1)
            y++;
        cout<<y<<endl;
    }return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        int a[n+1],b[n+1]={0},i,j,x,y,k;
        for(i=1;i<=n;i++)
        {
            cin>>a[i];
            b[i]=1;
        }
        for(i=n/2;i>0;i--)
        {
            k=i;
            while(1)
            {
                k=k+i;
                if(k>n)
                    break;
                if(a[k]>a[i])
                    b[i]=max(b[i],b[k]+1);
            }
        }
        sort(b,b+n+1);
        cout<<b[n]<<endl;
    }return 0;
}


#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define pb push_back
#define mp make_pair
#define F .first
#define S .second
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
using namespace std;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

ll a[110000];
vector<ll> dp(110000);
int main(){
    ll t,t2,sum;
    cin>>t;
    rep(z,0,t){
        dp.clear();
        ll n=0,m=0,fn;
        ll ans=1;
        cin>>n;
        rep(y,1,n+1)cin>>a[y];
        rep(i,1,n){
            rep(j,i+1,n+1){
                if(j%i==0&&a[j]>a[i])chmax(dp[j],dp[i]+1);
                chmax(dp[j],dp[i]);
            }
        }
        cout<<dp[n]+1<<endl;
    }
}


#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define pb push_back
#define mp make_pair
#define F .first
#define S .second
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
using namespace std;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

ll a[110000];
ll dp[110000];
int main(){
    ll t;
    cin>>t;
    rep(z,0,t){
        ll n,ans=0;
        cin>>n;
        rep(y,1,n+1)cin>>a[y];
        rep(i,0,n+1)dp[i]=1;
        rep(i,1,n+1){
            for(ll j=i*2;j<=n;j+=i){
                chmax(dp[j],dp[i]);
                if(a[j]>a[i])chmax(dp[j],dp[i]+1);
                ans=max(ans,dp[j]);
            }
        }
        cout<<ans<<endl;
    }
}


#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define pb push_back
#define mp make_pair
#define F .first
#define S .second
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
using namespace std;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

ll a[1200000],b[1200000];

ll f(ll c){
    ll ans=-1,k=2;
    while (c>=k*k) {
        if(c%k==0){
            ans=k;
            break;
       }
       else k++;
    }
    if(ans==-1)ans=c;
    return ans;
}
int main(){
    ll t,n,m,sum=0;
    cin>>t;
    rep(i,2,1000001){
        if(b[i]==0){
            b[i]=f(i);
            for(ll j=i*2;j<=1000001;j+=i){
                if(b[j]==0)b[j]=b[i];
            }
        }
    }
    rep(i,0,t){
        cin>>n>>m;
        ll x=n;
        if(n%2==0)x+=2*m;
        else x+=b[n]+2*(m-1);
        cout<<x<<endl;
    }
}


#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define pb push_back
#define mp make_pair
#define F .first
#define S .second
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
using namespace std;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

ll a[110000];
vector<ll> dp(110000);
int main(){
    ll t,t2,sum;
    cin>>t;
    rep(z,0,t){
        //dp.clear();
        ll n=0,m=0,fn;
        ll ans=1;
        cin>>n;
        rep(y,1,n+1)cin>>a[y];
        rep(i,1,n){
            rep(j,i+1,n+1){
                if(j%i==0&&a[j]>a[i])chmax(dp[j],dp[i]+1);
                chmax(dp[j],dp[i]);
            }
        }
        rep(i,0,n+1)dp[i]=0;
        cout<<dp[n]+1<<endl;
    }
}


#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define pb push_back
#define mp make_pair
#define F .first
#define S .second
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
using namespace std;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

ll a[110000];
ll dp[110000];
int main(){
    ll t;
    cin>>t;
    rep(z,0,t){
        ll n,ans=0;
        cin>>n;
        rep(y,1,n+1)cin>>a[y];
        rep(i,0,n+1)dp[i]=1;
        rep(i,1,n+1){
            for(ll j=i*2;j<=n;j+=i){
                chmax(dp[j],dp[i]);
                if(a[j]>a[i])chmax(dp[j],dp[i]+1);
                ans=max(ans,dp[j]);
            }
            ans=max(ans,dp[i]);
        }
        cout<<ans<<endl;
    }
}


#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define pb push_back
#define mp make_pair
#define F .first
#define S .second
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
using namespace std;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

ll a[110000];
ll dp[110000];
int main(){
    ll t;
    cin>>t;
    rep(z,0,t){
        ll n,ans=0;
        cin>>n;
        rep(y,1,n+1)cin>>a[y];
        rep(i,0,n+1)dp[i]=1;
        rep(i,1,n+1){
            for(ll j=i*2;j<=n;j+=i){
                chmax(dp[j],dp[i]);
                if(a[j]>a[i])chmax(dp[j],dp[i]+1);
            }
            ans=max(ans,dp[i]);
        }
        cout<<ans<<endl;
    }
}


#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define pb push_back
#define mp make_pair
#define F .first
#define S .second
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
using namespace std;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

ll a[110000];
vector<ll> dp(110000);
int main(){
    ll t,t2,sum;
    cin>>t;
    rep(z,0,t){
        //dp.clear();
        ll n=0,m=0,fn;
        ll ans=1;
        cin>>n;
        rep(y,1,n+1)cin>>a[y];
        rep(i,1,n){
            rep(j,i+1,n+1){
                if(j%i==0&&a[j]>a[i])chmax(dp[j],dp[i]+1);
                chmax(dp[j],dp[i]);
            }
        }
        cout<<dp[n]+1<<endl;
        rep(i,0,n+1)dp[i]=0;
    }
}


#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define pb push_back
#define mp make_pair
#define F .first
#define S .second
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
using namespace std;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

ll a[110000];
ll an[110];
int main(){
    ll t,t2,sum;
    cin>>t;
    rep(z,0,t){
        ll n,m,fn;
        ll ans=1;
        cin>>n;
        rep(y,0,n)cin>>a[y];
        rep(i,0,n-1){
            ll sum=1;
            fn=a[i];
            for(ll j=i+i;j<n;j+=i){
                if(fn<a[j]){sum++;fn=a[j];}
            }
            ans=max(ans,sum);
        }
       cout<<ans<<endl;
    }
}


#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define pb push_back
#define mp make_pair
#define F .first
#define S .second
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
using namespace std;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

ll a[110000];
ll dp[110000];
int main(){
    ll t;
    cin>>t;
    rep(z,0,t){
        ll n,ans=0;
        cin>>n;
        rep(y,1,n+1)cin>>a[y];
        rep(i,1,n+1){
            for(ll j=i*2;j<=n;j+=i){
                chmax(dp[j],dp[i]);
                if(a[j]>a[i])chmax(dp[j],dp[i]+1);
                ans=max(ans,dp[j]);
            }
        }
        cout<<ans+1<<endl;
        rep(i,0,n+1)dp[i]=0;
    }
}


#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define pb push_back
#define mp make_pair
#define F .first
#define S .second
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
using namespace std;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

ll a[110000];
ll dp[110000];
int main(){
    ll t;
    cin>>t;
    rep(z,0,t){
        ll n,ans=0;
        cin>>n;
        rep(y,1,n+1)cin>>a[y];
        rep(i,0,n+1)dp[i]=1;
        rep(i,1,n+1){
            for(ll j=i*2;j<=n;j+=i){
                if(a[j]>a[i])chmax(dp[j],dp[i]+1);
            }
            ans=max(ans,dp[i]);
        }
        cout<<ans<<endl;
    }
}


#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define pb push_back
#define mp make_pair
#define F .first
#define S .second
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
using namespace std;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

ll a[110000];
ll dp[110000];
int main(){
    ll t;
    cin>>t;
    rep(z,0,t){
        ll n,ans=0;
        cin>>n;
        rep(y,1,n+1)cin>>a[y];
        rep(i,0,n+1)dp[i]=1;
        rep(i,1,n+1){
            for(ll j=i*2;j<=n;j+=i){
                chmax(dp[j],dp[i]);
                if(a[j]>a[i])chmax(dp[j],dp[i]+1);
                ans=max(ans,dp[j]);
            }
        }
        cout<<ans+1<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;

long long ans=1;

void dfs(long long x,long long cnt,long long arr[],long long n)
{
    ans=max(ans,1LL*cnt);

    for(long i=x+x;i<=n;i+=x)
    {
        if(arr[x]<arr[i])
            dfs(i,cnt+1,arr,n);
        else
            dfs(i,1,arr,n);
    }
}

int main()
{
    int t;
    long long n,i;
    cin>>t;

    while(t--)
    {
        cin>>n;
        long long arr[n+1];

        for(i=1;i<=n;i++)
            cin>>arr[i];

        ans=1;
        dfs(1,1,arr,n);

        cout<<ans<<"\n";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    int t;
    cin>>t;
    long n,i,j;
    while(t--)
    {
        cin>>n;
        long long arr[n];

        for(i=0;i<n;i++)
            cin>>arr[i];

        long long dp[n+1][n+1];

        for(i=0;i<=n;i++)
            for(j=0;j<=n;j++)
                dp[i][j]=0;

        for(i=0;i<=n;i++)
            dp[0][i]=1;

        for(i=1;i<n;i++)
        {
            for(j=i+1;j<=n;j++)
            {
                if(j%i==0 && arr[j-1]>arr[i-1])
                    dp[i][j]=dp[i-1][i]+1;
                else
                    dp[i][j]=max(dp[i-1][j],max(dp[i-1][j-1],dp[i][j-1]));
            }
        }

        long long maxa=1;

        for(i=1;i<n;i++)
            for(j=i+1;j<=n;j++)
                if(dp[i][j]>maxa)
                    maxa=dp[i][j];

        cout<<maxa<<"\n";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

void dfs(long a,int vis[],int k,long cnt,long long arr[],long n,long &maxa)
{
    if(a*k<=n)
    if(vis[a*k]==0 && arr[a]<arr[a*k])
    {
        vis[a*k]=1;
        dfs(a*k,vis,2,cnt+1,arr,n,maxa);
    }

    k++;

    if(a*k<=n)
    {
        dfs(a,vis,k,cnt,arr,n,maxa);
    }
    else
    {
        if(cnt>maxa)
            maxa=cnt;

        return;
    }
    return;
}

int main()
{
    int t;
    long n,i;
    cin>>t;

    while(t--)
    {
        cin>>n;
        long long arr[n+1];

        for(i=1;i<=n;i++)
            cin>>arr[i];

        int vis[n+1];

        for(i=1;i<=n;i++)
            vis[i]=0;

        long maxa=0;

        dfs(1,vis,2,1,arr,n,maxa);

        cout<<maxa<<"\n";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    int t;
    cin>>t;
    long n,i,j;
    while(t--)
    {
        cin>>n;
        long long arr[n];

        for(i=0;i<n;i++)
            cin>>arr[i];

        long long dp[n+1][n+1];

        for(i=0;i<=n;i++)
            for(j=0;j<=n;j++)
                dp[i][j]=0;

        for(i=0;i<=n;i++)
            dp[0][i]=1;

        for(i=1;i<n;i++)
        {
            for(j=i+1;j<=n;j++)
            {
                if(j%i==0 && arr[j-1]>arr[i-1])
                    dp[i][j]=dp[i-1][i]+1;
                else
                    dp[i][j]=max(dp[i-1][j],dp[i-1][j-1]);
            }
        }

        cout<<dp[n-1][n]<<"\n";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int count=1;
int main()
{
    int t;
    cin>>t;

    long n,i,j;

    while(t--)
    {
        cin>>n;
        long long arr[n];

        for(i=0;i<n;i++)
            cin>>arr[i];

        unordered_map<long,vector<long>> connect;
        unordered_map<long,vector<long>>::iterator it;

        for(i=1;i<n;i++)
        {
            for(j=2*i;j<=n;j+=i)
            {

                if(arr[j-1]>arr[i-1])
                    connect[i].push_back(j);
            }
        }

        long long ans[n+1];

        ans[0]=0;
        for(i=1;i<=n;i++)
            ans[i]=1;

        for(i=1;i<n;i++)
        {
            for(j=i+1;j<=n;j++)
            {
                if(binary_search(connect[i].begin(),connect[i].end(),j))
                    ans[j]=ans[i]+1;
            }
        }
        cout<<*max_element(ans,ans+n+1)<<"\n";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    int t;
    cin>>t;
    long n,i,j;
    while(t--)
    {
        cin>>n;
        long long arr[n];

        for(i=0;i<n;i++)
            cin>>arr[i];

        long long dp[n+1][n+1];

        for(i=0;i<=n;i++)
            for(j=0;j<=n;j++)
                dp[i][j]=0;

        for(i=0;i<=n;i++)
            dp[0][i]=1;

        for(i=1;i<n;i++)
        {
            for(j=i+1;j<=n;j++)
            {
                if(j%i==0 && arr[j-1]>arr[i-1])
                    dp[i][j]=dp[i-1][i]+1;
                else
                    dp[i][j]=dp[i-1][j];
            }
        }

        long long maxa=1;

        for(i=1;i<n;i++)
            for(j=i+1;j<=n;j++)
                if(dp[i][j]>maxa)
                    maxa=dp[i][j];

        cout<<maxa<<"\n";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

void dfs(long long x,long long cnt,long long &ans,long long arr[],long long n)
{
    ans=max(ans,1LL*cnt);

    for(long i=x+x;i<=n;i+=x)
    {
        if(arr[x]<arr[i])
            dfs(i,cnt+1,ans,arr,n);
        else
            dfs(i,cnt,ans,arr,n);
    }
}

int main()
{
    int t;
    long long n,i;
    cin>>t;

    while(t--)
    {
        cin>>n;
        long long arr[n+1];

        for(i=1;i<=n;i++)
            cin>>arr[i];

        long long maxa=1;
        dfs(1,1,maxa,arr,n);
        cout<<maxa<<"\n";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

void dfs(long x,long cnt,long &ans,long long arr[],long n)
{
    ans=max(ans,cnt);

    for(long i=x+x;i<=n;i++)
    {
        if(arr[x]<arr[i])
            dfs(i,cnt+1,ans,arr,n);
        else
            dfs(i,cnt,ans,arr,n);
    }
}

int main()
{
    int t;
    long n,i;
    cin>>t;

    while(t--)
    {
        cin>>n;
        long long arr[n+1];

        for(i=1;i<=n;i++)
            cin>>arr[i];

        long maxa=1;
        dfs(1,1,maxa,arr,n);
        cout<<maxa<<"\n";
    }
    return 0;
}


#include <iostream>
#include <set>
#include <map>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <stack>
#include <queue>
#include <cmath>

using namespace std;

#define ll long long
#define vi vector<int>
#define ull unsigned long long
#define vull vector<ull>
#define vll vector<ll>
#define pii pair<int, int>
#define pll pair<ll, ll>

#define ld long double

int INF = 1e9 + 7;

vector<bool> primes(100001, true);
set<int> prm_s;

void erat()
{
    for (int i = 2; i <= 100000; i++)
        for (int j = i * 2; j <= 100000; j += i)
            primes[j] = false;
    for (int i = 1; i <= 100000; i++)
        if (primes[i]) prm_s.insert(i);
}

int main()
{
    int t;
    cin >> t;
    erat();
    while (t--)
    {
        ll n;
        cin >> n;
        vi s(n + 1);
        for (int i = 1; i <= n; i++)
            cin >> s[i];
        ll ans = 0;
        for(int i = 1; i <= n; i++)
            if (primes[i])
            {
                ll cur = 0;
                vector<pii> dp;
                dp.push_back({ s[i], i });
                map<int, pii> par;
                for (int k = i; k <= n; k++)
                {
                    auto it = lower_bound(dp.begin(), dp.end(), make_pair(s[k], -1));
                    if (it != dp.end() && (it == dp.end() - 1 || make_pair(s[k], k) < *(it + 1)))
                    {
                        *it = { s[k], k };
                        if (it == dp.begin()) par[s[k]] = { -1, -1 };
                        else par[s[k]] = *(it - 1);
                    }
                    else if (it == dp.end())
                    {
                        par[s[k]] = dp.back();
                        dp.push_back({ s[k], k });
                    }
                }
                stack<pii> seq;
                pii i = dp.back();
                while(i != make_pair(-1, -1))
                {
                    seq.push(i);
                    i = par[i.first];
                }
                ll prev = 1;
                while (!seq.empty())
                {
                    pii p = seq.top();
                    seq.pop();
                    if (p.second % prev == 0)
                    {
                        prev = p.second;
                        cur++;
                    }
                }
                ans = max(ans, cur);
            }
        cout << ans << '\n';
    }
}


#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>

using namespace std;

#define ll long long
#define vi vector<int>
#define ull unsigned long long
#define vull vector<ull>
#define vll vector<ll>
#define pii pair<int, int>
#define pll pair<ll, ll>

#define ld long double

int INF = 1e9 + 7;

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        vi s(n + 1);
        for (int i = 1; i <= n; i++)
            cin >> s[i];
        vi dp(n + 1);
        dp[1] = 1;
        for (int i = 2; i <= n; i++)
        {
            for (ll div = 1; div * div <= i + 1; div++)
            {
                if (i % div == 0 && s[div] < s[i]) dp[i] = max(dp[i], dp[div] + 1);
                if (i % div == 0 && s[i / div] < s[i]) dp[i] = max(dp[i], dp[i / div] + 1);
            }
        }
        int ans = 0;
        for (int i = 1; i <= n; i++)
            ans = max(ans, dp[i]);
        cout << ans << '\n';
    }
}


#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>

using namespace std;

#define ll long long
#define vi vector<int>
#define ull unsigned long long
#define vull vector<ull>
#define vll vector<ll>
#define pii pair<int, int>
#define pll pair<ll, ll>

#define ld long double

int INF = 1e9 + 7;

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        vi s(n + 1);
        for (int i = 1; i <= n; i++)
            cin >> s[i];
        vi dp(n + 1, 1);
        for (int i = 2; i <= n; i++)
        {
            for (ll div = 1; div * div <= i; div++)
            {
                if (i % div == 0 && s[div] < s[i]) dp[i] = max(dp[i], dp[div] + 1);
                if (i % div == 0 && s[i / div] < s[i]) dp[i] = max(dp[i], dp[i / div] + 1);
            }
        }
        int ans = 0;
        for (int i = 1; i <= n; i++)
            ans = max(ans, dp[i]);
        cout << ans << '\n';
    }
}


#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>

using namespace std;

#define ll long long
#define vi vector<int>
#define ull unsigned long long
#define vull vector<ull>
#define vll vector<ll>
#define pii pair<int, int>
#define pll pair<ll, ll>

#define ld long double

int INF = 1e9 + 7;

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        vi s(n);
        for (int i = 0; i < n; i++)
            cin >> s[i];
        vi dp(n);
        dp[0] = 1;
        for (int i = 1; i < n; i++)
        {
            for (int div = 1; div * div <= (i + 1); div++)
            {
                if ((i + 1) % div == 0 && s[div - 1] < s[i]) dp[i] = max(dp[i], dp[div - 1] + 1);
                if ((i + 1) % div == 0 && div > 1 && s[(i + 1) / div - 1] < s[i]) dp[i] = max(dp[i], dp[(i + 1) / div - 1] + 1);
            }
        }
        int ans = 0;
        for (int i = 0; i < n; i++)
            ans = max(ans, dp[i]);
        cout << ans << '\n';
    }
}


#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>

using namespace std;

#define ll long long
#define vi vector<int>
#define ull unsigned long long
#define vull vector<ull>
#define vll vector<ll>
#define pii pair<int, int>
#define pll pair<ll, ll>

#define ld long double

int INF = 1e9 + 7;

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        vi s(n);
        for (int i = 0; i < n; i++)
            cin >> s[i];
        vi dp(n);
        dp[0] = 1;
        for (int i = 1; i < n; i++)
        {
            for (int div = 1; div * div <= i; div++)
            {
                if ((i + 1) % div == 0 && s[div - 1] < s[i]) dp[i] = max(dp[i], dp[div - 1] + 1);
                if ((i + 1) % div == 0 && div > 1 && s[(i + 1) / div - 1] < s[i]) dp[i] = max(dp[i], dp[(i + 1) / div - 1] + 1);
            }
        }
        int ans = 0;
        for (int i = 0; i < n; i++)
            ans = max(ans, dp[i]);
        cout << ans << '\n';
    }
}


#include <iostream>
#include <set>
#include <map>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <stack>
#include <queue>
#include <cmath>

using namespace std;

#define ll long long
#define vi vector<int>
#define ull unsigned long long
#define vull vector<ull>
#define vll vector<ll>
#define pii pair<int, int>
#define pll pair<ll, ll>

#define ld long double

int INF = 1e9 + 7;

vector<bool> primes(100001, true);
set<int> prm_s;

void erat()
{
    for (int i = 2; i <= 100000; i++)
        for (int j = i * 2; j <= 100000; j += i)
            primes[j] = false;
    for (int i = 1; i <= 100000; i++)
        if (primes[i]) prm_s.insert(i);
}

int main()
{
    int t;
    cin >> t;
    //erat();
    while (t--)
    {
        ll n;
        cin >> n;
        vi s(n + 1);
        for (int i = 1; i <= n; i++)
            cin >> s[i];
        vector<vi> dp;
        ll ans = 1;
        for (int i = 2; i <= n; i++)
        {
            ll cur = 0;
            ll prev = -1;
            for(int j = i; j <= n; j *= 2)
                if (s[j] > prev)
                {
                    prev = s[j];
                    cur++;
                }
            if (s[1] < s[i]) cur++;
            ans = max(ans, cur);
        }
        cout << ans << '\n';
    }
}


#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>

using namespace std;

#define ll long long
#define vi vector<int>
#define ull unsigned long long
#define vull vector<ull>
#define vll vector<ll>
#define pii pair<int, int>
#define pll pair<ll, ll>

#define ld long double

int INF = 1e9 + 7;

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        vi s(n + 1);
        for (int i = 1; i <= n; i++)
            cin >> s[i];
        vi dp(n + 1);
        dp[1] = 1;
        for (int i = 2; i <= n; i++)
        {
            for (ll div = 1; div * div <= i; div++)
            {
                if (i % div == 0 && s[div] < s[i]) dp[i] = max(dp[i], dp[div] + 1);
                if (i % div == 0 && s[i / div] < s[i]) dp[i] = max(dp[i], dp[i / div] + 1);
            }
        }
        int ans = 0;
        for (int i = 1; i <= n; i++)
            ans = max(ans, dp[i]);
        cout << ans << '\n';
    }
}


#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>

using namespace std;

#define ll long long
#define vi vector<int>
#define ull unsigned long long
#define vull vector<ull>
#define vll vector<ll>
#define pii pair<int, int>
#define pll pair<ll, ll>

#define ld long double

int INF = 1e9 + 7;

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        vi s(n);
        for (int i = 0; i < n; i++)
            cin >> s[i];
        vi dp(n);
        dp[0] = 1;
        for (int i = 1; i < n; i++)
        {
            for (int div = 1; div * div <= i; div++)
            {
                if (i % div == 0 && s[div] < s[i]) dp[i] = max(dp[i], dp[div] + 1);
                if (i % div == 0 && div > 1 && s[i / div] < s[i]) dp[i] = max(dp[i], dp[div] + 1);
            }
        }
        int ans = 0;
        for (int i = 0; i < n; i++)
            ans = max(ans, dp[i]);
        cout << ans << '\n';
    }
}


#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>

using namespace std;

#define ll long long
#define vi vector<int>
#define ull unsigned long long
#define vull vector<ull>
#define vll vector<ll>
#define pii pair<int, int>
#define pll pair<ll, ll>

#define ld long double

int INF = 1e9 + 7;

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        vi s(n + 1);
        for (int i = 1; i <= n; i++)
            cin >> s[i];
        vi dp(n + 1, 1);
        for (int i = 1; i <= n; i++)
            for (int j = 2 * i; j <= n; j += i)
                if(s[j] > s[i]) dp[j] = max(dp[j], dp[i] + 1);
        int ans = 0;
        for (int i = 1; i <= n; i++)
            ans = max(ans, dp[i]);
        cout << ans << '\n';
    }
}


/*
csc -debug C.cs && mono --debug C.exe <<< "2
1 2"

csc -debug C.cs && mono --debug C.exe <<< "5
2 2 1 22 14"

time (csc C.cs && mono C.exe)
*/

using System;
using System.Collections.Generic;
using System.Linq;

public class HelloWorld {
    static public void Main () {
        SolveCodeForces();
    }

    // 511969795 - 0m6.196s
    public static IEnumerable<ulong> GetDivisors(ulong n, ulong maxdiv) {
        var divs = new List<ulong>();
        for (var d = 1ul; d <= maxdiv && d * d <= n; d++)
            if (n % d == 0) {
                divs.Add(d);
                var e = n / d;
                if (e <= maxdiv && e != d)
                    yield return e;
            }
        for (var i = divs.Count - 1; i >= 0; i--)
            yield return divs[i];
    }

    // 511969795 - 0m6.061s
    public static IEnumerable<ulong> GetDivisors2(ulong n, ulong maxdiv) {
        return GetDivisors2_Inner(n, maxdiv).OrderByDescending(a => a);
    }

    public static IEnumerable<ulong> GetDivisors2_Inner(ulong n, ulong maxdiv) {
        for (var d = 1ul; d <= maxdiv && d * d <= n; d++)
            if (n % d == 0) {
                yield return d;
                var e = n / d;
                if (e <= maxdiv && e != d)
                    yield return e;
            }
    }

    private static List<ulong>[] divisors3;
    public static void PrepareDivisors3(ulong n) {
        divisors3 = Helpers.CreateArray((int)n + 1, _ => new List<ulong>());
        for (var d = 2ul; d * d <= n; d++)
            for (var k = d; k <= n; k += d)
                divisors3[k].Add(d);
        // for (var i = 2; i <= 50; i++)
        //     System.Console.WriteLine(i + ": " + string.Join(" ", divisors3[i]));
    }
    public static IEnumerable<ulong> GetDivisors3(ulong n, ulong maxdiv) {
        var divs = divisors3[n];
        for (var i = divs.Count - 1; i >= 0; i--)
            if (divs[i] <= maxdiv)
                yield return divs[i];
    }

    public static void SolveCodeForces() {
        Console.ReadLine();
        var A = Console.ReadLine().Split().Select(ulong.Parse).ToArray();
        var rnd = new Random(123);
        // var A = Enumerable.Repeat(0, 1000000).Select(_ => (ulong)rnd.Next(1, 100)).ToArray(); // 397377512 - 0m2.559s
        // var A = Enumerable.Repeat(0, 100000).Select(_ => (ulong)rnd.Next(800000, 1000000)).ToArray(); // 278159192 - 0m3.328s
        // var A = Enumerable.Repeat(0, 100000).Select(_ => (ulong)rnd.Next(7500000, 10000000)).ToArray(); // 511969795 - 0m6.339s
        var n = (ulong)A.Length;

        PrepareDivisors3(A.Max());

        const ulong MOD = 1000000007ul;

        var B = new ulong[n+1];
        B[1] = 1;

        for (var i = 1; i < A.Length; i++) {
            foreach (var div in GetDivisors3(A[i], n))
                B[div] = (B[div] + B[div-1]) % MOD;
            B[1]++;
            // System.Console.WriteLine(new {a = A[i], B = string.Join(" ", B)});
        }

        var ans = 0ul;
        foreach (var c in B)
            ans = (ans + c) % MOD;

        System.Console.WriteLine(ans % MOD);
    }
}

public static class Helpers {
    public static T[] CreateArray<T>(int length, Func<int, T> itemCreate) {
        var result = new T[length];
        for (var i = 0; i < result.Length; i++)
            result[i] = itemCreate(i);
        return result;
    }

    public static T ElementWithMax<T>(this IEnumerable<T> seq, Func<T, long> func) {
        var bi = default(T);
        var bv = long.MinValue;
        foreach (var item in seq) {
            var v = func(item);
            if (v > bv) {
                bi = item;
                bv = v;
            }
        }
        return bi;
    }

    public static IEnumerable<int> IndicesWhere<T>(this IEnumerable<T> seq, Func<T, bool> cond) {
        var i = 0;
        foreach (var item in seq) {
            if (cond(item)) yield return i;
            i++;
        }
    }
}


using System;

public class Program
{

	public static void Main()
	{
		int arrayLength = Int32.Parse(Console.ReadLine());
		string numberString = Console.ReadLine();
		string[] numbersString = numberString.Split(' ');
		int[] numbers = new int[arrayLength];

		int result = 0;

		for(int i = 0; i< arrayLength; i++){
			numbers[i] = Int32.Parse(numbersString[i]);

		}

		for(int i = 0; i< arrayLength; i++){
					if(numbers[i]%1 == 0){
				result++;
			}
			bool moretest = false;
			int pos = 2;
			do{
				moretest = false;
				for(int j = 1; j< arrayLength-i; j++){
					if(numbers[i+j]%pos == 0){
						result++;
						moretest = true;
					}
				}
				pos++;
			}while(moretest);
		}
		result = (int)(result % (Math.Pow(10, 9) +7 ));

		Console.WriteLine(result);

	}
}


using System;

public class Program
{

	public static void Main()
	{
		int arrayLength = Int32.Parse(Console.ReadLine());
		string numberString = Console.ReadLine();
		string[] numbersString = numberString.Split(' ');
		int[] numbers = new int[arrayLength];

		for(int i = 0; i< arrayLength; i++){
			numbers[i] = Int32.Parse(numbersString[i]);
		}

		int[] CounterDiv = new int[1000001];
		for(int x = 1000000; x > 0; x--){
			for(int y = x; y < 1000001; y+=x)
				CounterDiv[y]++;
		}

		int[][] Divid = new int[1000001][];
		for(int x = 1; x < 1000001; x++){
			Divid[x] = new int[CounterDiv[x]];
		}

		int[] second = new int[1000001];
		for(int x = 1000000; x > 0; x--){
			for(int y = x ; y < 1000001; y+=x){
				Divid[y][second[y]++] = x;
			}
		}

		long modulo =  (long)(Math.Pow(10,9) + 7);

		long[] answer = new long[1000001];
		answer[0] = 1;

		for(int x = 0; x < arrayLength; x++){
			foreach(int y in Divid[numbers[x]]){
				answer[y] = (answer[y] + answer[y -1]) % modulo;
			}
		}

		long result = 0;
		for(int x = 1; x < 1000001; x++){
			result = (result + answer[x]) % modulo;
		}

		Console.WriteLine(result);

	}
}


using System;

namespace Multiplicity_1061C
{
    class Program
    {
        static void Main(string[] args)
        {

            //System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            //sw.Start();

            int size = Convert.ToInt32(Console.ReadLine());
            int[] inputArr = new int[size];

            string input = Console.ReadLine();

            string[] nums = input.Split(' ');

            for (int i = 0; i < size; i++)
            {
                inputArr[i] = Convert.ToInt32(nums[i]);
            }

            long answer = 0;

            int[] divCnt = new int[1000001];
            for (int i = 1000000; i >= 1; --i)
            {
                for (int j = i; j <= 1000000; j += i)
                    divCnt[j]++;
            }

            int[][] divisorsArr = new int[1000001][];
            for (int i = 0; i < 1000001; i++)
            {
                divisorsArr[i] = new int[divCnt[i]];
            }

            int[] pointer = new int[1000001];
            for (int n = 0; n < 1000001; n++)
            {
                pointer[n] = 0;
            }
            for (int i = 1000000; i >= 1; --i)
            {
                for (int j = i; j < 1000001; j += i)
                {
                    divisorsArr[j][pointer[j]++] = i;
                }
            }

            long module = 1000000007;
            long[] ansArr = new long[1000001];
            ansArr[0] = 1;

            for (int i = 0; i < size; i++)
            {
                foreach (var n in divisorsArr[inputArr[i]])
                {

                    ansArr[n] = (ansArr[n] + ansArr[n - 1]) % module;
                }
            }

            for (int i = 1; i < 1000001; i++)
            {
                answer = (answer + ansArr[i]) % module;
            }

            //sw.Stop();
           // Console.Write("Время: " + sw.ElapsedMilliseconds / 1000.00 + "\n");
            Console.Write(answer);
        }

    }
}


using System;

namespace Multiplicity_1061C
{
    class Program
    {
        static void Main(string[] args)
        {

            //System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            //sw.Start();

            int size = Convert.ToInt32(Console.ReadLine());
            int[] inputArr = new int[size];

            string input = Console.ReadLine();

            string[] nums = input.Split(' ');

            for (int i = 0; i < size; i++)
            {
                inputArr[i] = Convert.ToInt32(nums[i]);
            }

            long answer = 0;

            int[] divCnt = new int[1000001];
            for (int i = 1000000; i >= 1; --i)
            {
                for (int j = i; j <= 1000000; j += i)
                    divCnt[j]++;
            }

            int[][] divisorsArr = new int[1000001][];
            for (int i = 0; i < 1000001; i++)
            {
                divisorsArr[i] = new int[divCnt[i]];
            }

            int[] pointer = new int[1000001];
            for (int n = 0; n < 1000001; n++)
            {
                pointer[n] = 0;
            }
            for (int i = 1000000; i >= 1; --i)
            {
                for (int j = i; j < 1000001; j += i)
                {
                    divisorsArr[j][pointer[j]++] = i;
                }
            }

            long module = 1000000007;
            long[] ansArr = new long[1000001];
            ansArr[0] = 1;

            for (int i = 0; i < size; i++)
            {
                foreach (var n in divisorsArr[inputArr[i]])
                {

                    ansArr[n] = (ansArr[n] + ansArr[n - 1]) % module;
                }
            }

            for (int i = 0; i < 1000001; i++)
            {
                answer += ansArr[i] % module;
            }

            //sw.Stop();
           // Console.Write("Время: " + sw.ElapsedMilliseconds / 1000.00 + "\n");
            Console.Write(answer - 1);
        }

    }
}


using System;

namespace Multiplicity_1061C
{
    class Program
    {
        static void Main(string[] args)
        {

            //System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            //sw.Start();
            int size = Convert.ToInt32(Console.ReadLine());
            int[] inputArr = new int[size];

            string input = Console.ReadLine();

            string[] nums = input.Split(' ');

            for (int i = 0; i < size; i++)
            {
                inputArr[i] = Convert.ToInt32(nums[i]);
            }

            long answer = 0;

            int[] divCnt = new int[1000001];
            for (int i = 1000000; i >= 1; --i)
            {
                for (int j = i; j <= 1000000; j += i)
                    divCnt[j]++;
            }

            int[][] divisorsArr = new int[1000001][];
            for (int i = 0; i < 1000001; i++)
            {
                divisorsArr[i] = new int[divCnt[i]];
            }

            int[] pointer = new int[1000001];
            for (int n = 0; n < 1000001; n++)
            {
                pointer[n] = 0;
            }
            for (int i = 1000000; i >= 1; --i)
            {
                for (int j = i; j < 1000001; j += i)
                {
                    divisorsArr[j][pointer[j]++] = i;
                }
            }

            int module = 1000000007;
            int[] ansArr = new int[1000001];
            ansArr[0] = 1;

            for (int i = 0; i < size; i++)
            {
                foreach (var n in divisorsArr[inputArr[i]])
                {
                    ansArr[n] = (ansArr[n] + ansArr[n - 1]) % module;
                }
            }

            for (int i = 0; i < 1000001; i++)
            {
                answer += ansArr[i];
            }

            //sw.Stop();
           // Console.Write("Время: " + sw.ElapsedMilliseconds / 1000.00 + "\n");
            Console.Write(answer - 1);
        }

    }
}