#include<bits/stdc++.h>
using namespace std;
#define int long long
#define MAX 1000000;
#define mod 1000000007
//#define INF 1000000007
#define pb push_back
#define ff first
#define ss second
#define w(tt) int tt;cin>>tt;while(tt--)
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int32_t main(){
w(tt){
int n;cin>>n;
int a[n+1],dp[n+1];
for(int i=1;i<=n;i++)cin>>a[i];
for(int i=n;i>=1;i--){
	dp[i]=a[i]+((i+a[i]<=n)?dp[i+a[i]]:0);
	}
cout<<*max_element(dp+1,dp+n+1)<<endl;
	}
return 0;
}
 
 
 
 
 
 
 
 
 
 
 
 
 
