#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        vector<ll>a(n);
        for(ll i=0;i<n;i++)
        {
            cin>>a[i];
        }
        ll maxi=INT_MIN;
        for(ll i=n-1;i>-1;i--)
        {
            ll total=0;
            total+=a[i];
            if(i+a[i]<n)
            {
                total+=a[i+a[i]];
            }
            a[i]=total;
            maxi=max<ll>(maxi,total);
        }
        //cout<<"\t";
        cout<<maxi<<"\n";
    }
}