#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define all(x) x.begin(),x.end()
#define pb emplace_back
#define pob pop_back()
#define ms0(s) memset(s,0,sizeof s)
#define ff first
#define ss second
typedef long long int ll;
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define vvll vector<vector<ll>>
#define pll pair<ll,ll>
#define prq priority_queue<ll>  //max-heap
#define psq priority_queue<ll,vector<ll>,greater<ll>>  //min-heap
#define m_p make_pair
#define vcc vector<char>
#define vss vector<string>
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define setbit(n) __builtin_popcountll(n)
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t = 1;
	cin >> t;
	while (t--)
	{
		ll i, j, k, n, m;
		cin >> n;
		vll a(n);
		vll ans(n);
		for (i = 0; i < n; i++)
			cin >> a[i], ans[i] = a[i];
		for (i = n - 1; i >= 0; i--)
			if (i + a[i] < n)
			{
				ans[i] += ans[i + a[i]];
			}
		ll res = 0;
		for (i = 0; i < n; i++)
			res = max(res, ans[i]);
		cout << res << "\n";
	}
	return 0;
}