#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int main()
{
  ll t;
  cin>>t;
  while(t--){
    ll n;
    cin>>n;

    vector<ll> arr(n);
    for(int i=0;i<n;i++) cin>>arr[i];

    ll ans=INT_MIN;
    ans=max(ans,arr[n-1]);
    for(ll i=n-2;i>=0;i--){
      if(arr[i]+i<n)
      arr[i]+= arr[arr[i]+i];
      ans=max(ans,arr[i]);
    }
    cout<<ans<<endl;
  }
  return 0;
}
