#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int a[N];
int s[N];
int n;

long long dfs(long long x){
    if(x>n)return 0;
    if(s[x])return s[x];
    s[x]=dfs(x + a[x])+a[x];
    return s[x];
}

void solve(){
    scanf("%d", &n);
    for (int i = 0; i < n;i++)
        scanf("%d", &a[i+1]);
    memset(s, 0, sizeof(int) * (n+1));
    long long ans = dfs(1);
    for (int i = 1; i <= n;i++){
        ans = max(ans, dfs(i));
    }
    printf("%lld\n", ans);
}

int main(){
    int t;
    scanf("%d", &t);
    while(t--)
        solve();
    return 0;
}