 #include<iostream>
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
using namespace std;
 
 


int main()
{  
     #ifndef ONLINE_JUDGE
     //for getting input from file input.txt
     freopen("input.txt","r",stdin);
    //for writing output to output.txt
     freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false); cin.tie(NULL);
  


  ll t;
  cin>>t;
  
  
  while(t--)
  {
    ll i,j,n,sum=0,one=0,two=0;
    cin>>n;
    ll a[n];
    for(i=0;i<n;i++)
        cin>>a[i];
   ll dp[n];

   dp[n-1] = a[n-1];

   for(i=n-2;i>=0;i--)
   {
    if(i+a[i]<n)
    dp[i] = a[i] + dp[i+a[i]];
else
    dp[i] = a[i];

   }
   cout<<*max_element(dp,dp+n)<<endl;


  } 

}
 
 
 