#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll mod= 998244353;

 
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        vector<ll>a(n,0);
        
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
        }
        vector<int>score(n,0);
        score[n-1]=a[n-1];
        for(int i=n-2;i>=0;i--)
        {
            if(i+a[i]<n)score[i]=a[i]+score[i+a[i]];
            else score[i]=a[i];
        }
       cout<<*max_element(score.begin(),score.end())<<"\n";


    }

}