#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vc vector<char>
#define all(v) v.begin(),v.end()
vl t(200002,-1);
vl a;
int n;
ll dp(int x){
    

    if(x>=n) return 0;
    if(t[x]!=-1) return t[x];
   
    ll temp=a[x]+dp(x+a[x]);
    t[x]=temp;
   
    return temp;
}
void solve(){
    cin>>n;
    a.resize(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll ans=0;
    for(auto &i:t) i=-1;
    for(int i=0;i<n;i++){
        ans=max(ans,dp(i));
    }
    cout<<ans<<endl;
}
int main(){
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   int t;
   cin>>t;
   while(t--) solve();
   return 0;
}