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

void cpc(){
   int n;
   cin>>n;
   int arr[n+1];
   int sum[n+1];
   for(int i = 1;i<=n;i++){
      cin>>arr[i];
      sum[i] = 0;
   }
     
     int mx = INT_MIN;
   for(int i = n; i>=1;i--){
       int ind = i+arr[i];
       sum[i]+=arr[i];
       if(ind<=n)
         sum[i]+=sum[ind];
        
        mx = max(mx,sum[i]);
   }
   cout<<mx<<"\n";
}


int main() {
    int t;
    cin>>t;
    while(t--){
        cpc();
    }
}
