#include<bits/stdc++.h>
#define ll long long int
using namespace std;

ll func(ll i,ll n,ll *a)
{
  //  ll k=a[i];
    
    if(i>=n)
    {
        return 0;
    }
    else
    {
        a[i]=a[i]+func(i+a[i],n,a);
        return a[i];
    }
    
    
}

ll tc()
{
    ll n,k;
    cin>>n;
    ll i;
    ll a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    vector<ll>b;
    ll y;
    for(i=0;i<n;i++)
    {
        y=func(i,n,a);
        b.push_back(y);
    }
    ll j=*max_element(b.begin(),b.end());
    return j;
    
}

int main()
{
    ll t;
    cin>>t;
    vector<ll>a;
    ll i,y;
    for(i=0;i<t;i++)
    {
        y=tc();
        a.push_back(y);
    }
    for(i=0;i<t;i++)
    {
        cout<<a[i]<<endl;
    }
    
    
    
    
}