#include <bits/stdc++.h>

int main() {
    int test=1;
    scanf("%d",&test);
    typedef long long iint;
    while(test--){
    	int n;
    	scanf("%d",&n);
    	iint arr[n],dp[n];
    	for(int i=0;i<n;++i){
    		scanf("%lld",&arr[i]);
    	}
    	dp[n-1] = arr[n-1];
    	iint ans = dp[n-1];
    	for(int i=n-2;i>=0;--i){
    		dp[i] = arr[i];
    		if(i+arr[i]<n){
    			dp[i] += dp[i+arr[i]];
    		}
    		ans = std::max(ans, dp[i]);
    	}
    	printf("%lld\n",ans);
    }
    return 0;
}