#include <bits/stdc++.h>

using namespace std;

#define optimizze() 		ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define watch(x) 		cout << (#x) << " is " << (x) << endl
#define ll				long long
#define yes				cout << "YES"<<"\n"
#define no				cout << "NO"<<"\n"
#define w(x)			int x; cin>>x; while(x--)
#define F 				first
#define S 				second
#define pb				push_back
#define all(x) 			x.begin(), x.end()


int main()
{
	optimizze();
	//.......................//

	w(t)
	{
		ll n;
		cin >> n;
		vector<ll> v(n);
		ll o = 0, tw = 0;
		for (int i = 0; i < n; ++i)
		{
			cin >> v[i];

		}
		vector<ll> sum(n, 0);
		for (int i = n - 1; i >= 0; --i)
		{
			o = 0;
			for (int j = i; j < n;)
			{
				if (sum[j])
				{
					o += sum[j];
					break;
				} else
				{
					o += v[j];
					j += v[j];
				}
			}
			sum[i] = o;
		}
		sort(all(sum));
		cout << sum.back() << endl;
	}

	return 0;
}

