#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int32_t main(){
    IOS;
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        int a[n],dp[n];
        for(int i = 0;i < n; i++){
            cin >> a[i];
            dp[i] = a[i];
        }
        for(int i = n-1;i >= 0; i--){
            if(dp[i]+i>=n)
                continue;
            else{
                dp[i] += dp[dp[i]+i];
            }
        }
        int ans = -1;
        for(int i = 0;i < n; i++){
            ans = max(ans,dp[i]);
        }
        cout << ans << "\n";
    }
    return 0;
}