#include<bits/stdc++.h>
#define X first
#define Y second
#define eb emplace_back
#define pb push_back
#define print1d(x) for(auto i : x){ cout << i << " ";} cout << '\n'
#define print2d(x) for(auto u : x){ print1d(u);} cout << "------" << '\n'
#define CLR(x, y) memset(x, y, sizeof(x))
#define ALL(X) X.begin(), X.end()
#define io_o() ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define mp(x, y) make_pair(x, y)
#define mpp(w, x, y, z) make_pair(mp(w, x), mp(y, z))
#define FOR(i, n) for(int i = 0; i < n; i++)
#define FOR1(i, n, m) for(int i = n; i < m; i++)
#define FOR2(X) for(auto x : X)
#define maxn 200005
#define mod (1e9)+7
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
//priority_queue<ll> pq; priority_queue<pii,vector<pii>, greater<pii>> pq;
ll a[200005], tbl[200005];

int main(){
	io_o(); //cute!
	int t; cin >> t;
	while(t--){
		int n; cin >> n;
		FOR(i, n){
			cin >> a[i];
		}
		tbl[n-1] = a[n-1];
		for(int i = n-2; i >= 0; i--){
			if(i + a[i] < n){
				tbl[i] = a[i] + tbl[i + a[i]];
			}else tbl[i] = a[i];
		}
		ll maxx = 0;
		for(int i = 0; i < n; i++){
			maxx = max(maxx, tbl[i]);
		}
		cout << maxx << '\n';
	}
	
	return 0;
}
