#include <bits/stdc++.h> 
using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vpii = vector<pii>;

#define TEST(t) int t; cin >> t; while(t--)
#define FOR(i,a,b) for(int i=a; i<b; i++)
#define RFOR(i,a,b) for(int i=a; i>b; i--)
#define print(a) cout << a << endl
#define print_vec(v) for(auto i : v) {cout << i << " ";} cout << endl
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define ALL(v) v.begin(), v.end()

int main() 
{ 
	TEST(t) {
		int n; cin >> n;
		vi a(n);
		FOR(i,0,n) {cin >> a[i];}
		// reverse(ALL(a));

		vi dp(n);
		RFOR(i,n-1,-1) {
			if(a[i] + i > n-1) {
				dp[i] = a[i];
			} else {
				dp[i] = a[i] + dp[i + a[i]];
			}
		}

		int mx = -1;
		for(auto i : dp) {
			if(i > mx) mx = i;
		}

		print(mx);

	}
} 