     #include<bits/stdc++.h>
        using namespace std;
        #define ll long long  
        #define pb push_back
        #define f first
        #define s second
        
        void solve()
        {
            ll i,j,k,m=0,n;
            cin>>n;
            ll a[n];
            for(i=1;i<=n;i++)
            cin>>a[i];
            
            for(i=n;i>=1;i--)
            {
                if(i+a[i] <= n)
                    a[i]=a[i]+a[i+a[i]];
                
                m=max(a[i],m);
            }
            cout<<m<<"\n";
        }
        
        int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);cout.tie(NULL);
        ll t;
        cin>>t;
        while(t--) solve();
        }
        
        