//PRiyabrat Bania///
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define endl "\n"
#define Fc ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
#define tc int t;cin>>t;while(t--) 
#define fr(i,a,b) for(int i=a;i<b;i++)
int mod = 1000000007;
#define vi vector<int>
#define vip vector<pair<int,int>>/*for other pair make in code*/
#define VS vector<string>
#define VC vector<char>
#define F first
#define S second
#define pb push_back
#define mpr make_pair
#define null NULL
#define str string
#define all(X) X.begin(),X.end()
const int N = 1e6 + 1;
const int MAX = 1000001; 

// array to store prime factors 
int factor[MAX] = { 0 };
vi siv(MAX);
/***************//***********************************/
// Sieve //
void sieve(int n) 
{ 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          siv.pb(p); 
} 
////////////////////////////////////
void primeNum()
{
    factor[1] = 1;

    for(int i = 2;i<MAX;i++)
      factor[i] = i;
    
    for(int i = 4;i < MAX;i+=2)
      factor[i] = 2;

    for(int i = 3;i*i < MAX; i++)
    {
        if(factor[i] == i){
            for(int j = i*i;j<MAX;j+=1){
                if(factor[j] == j)
                   factor[j] = i;
            }
        }
    }
}
//sieve///////////////************************/////
//////////**********GCD***************/////////////////////
int power(int a, int b)
{
    long long ans = 1;
    while (b > 0)
    {
        if (b & 1LL)
        {
            ans = (ans * a) % mod;
        }
        a = (a * a) % mod;
        b = (b >> 1LL);
    }
    return ans;
}
///////////////power/////////////////////////////
int gcd(int a, int b){

if(b==0) return a;

else return gcd(b,a%b);

}
//////////////////*///////*/////////////*////////////////////

void solve()
{
    int n; cin>>n;
    int a[n];
    fr(i,0,n) cin>>a[i];

    vi v(n);
    int k =0;
    for(int i = n-1;i>=0;i--)
    {
        k = a[i];
        if(a[i]+i<=n-1)
        k = a[i] + v[a[i]+i];
        v[i] = k;
    }
    
    int ans = *max_element(v.begin(),v.end());
    cout<<ans<<endl;
}
int32_t main()
{
    Fc;
    tc
   solve();
}