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

#define print(v) for(auto x : v) cout<<x<<' '; cout<<endl;
#define pprint(v) for(auto x : v) cout<<x.first<<' '<<x.second<<endl;

int main()
{
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	int t; cin>>t;
	for(;t--;cout<<endl)
	{
		long long n, i, j, k; cin>>n;
		vector <pair <long long, long long>> v;
		for(i=0;i<n;i++) cin>>j, v.push_back({j, j});
		for(i=k=0;i<n;i++)
		{
			j=i+v[i].first;
			if(j>=n) k=max(k, v[i].second);
			else v[j].second=max(v[j].second, v[j].first+v[i].second);
		}
		for(auto x : v) k=max(k, x.second);
		cout<<k;
	}
	return 0;
}