
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll MOD = 1000000007;
ll small(ll a,ll b)
{
        if(a<b)
                return a;
        return b;
}
ll large(ll a,ll b)
{
        if(a>b)
                return a;
        return b;
}
ll lcm(ll a,ll b)
{
        if(a==b)
                return a;
        if(a==1||b==1)
                return(1);
        if(a>b)
                return(lcm(a-b,b));
        return(lcm(a,b-a));
}
 int main()
{
        ll t;
         cin>>t;
         while(t--)
         {
                 ll n,i,j,ans=0,k,s=0,pa=0,x=0,x1,y=0,x2,y2;
                 cin>>n;
                 vector<ll>v(n,0),dp(n,0);
                 for(i=0;i<n;i++)
                 {
                         cin>>v[i];
                 }
                // dp[0]=v[0];
                 ans=dp[0];
                 for(i=0;i<n;i++)
                 {
                         dp[i]=dp[i]+v[i];
                         if((i+v[i])<n)
                         {
                         dp[i+v[i]]=max( dp[i+v[i]],dp[i]);
                         ans=max(ans,dp[i+v[i]]);
                         
                          }
                          ans=max(ans,dp[i]);
                        //cout<<dp[i]<<endl;
          // cout<< i+v[i]<<" " <<dp[i+v[i]]<<endl;
                 }
                 cout<<ans<<endl;
                 
         }
}