#include<iostream>
#include<algorithm>
#include<math.h>
#include<string.h>
#include <vector> 
#include <iterator> 

using namespace std;



void solve()
{
    int n;
    cin >> n;

    int a[n], b[n];

    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        b[i] = 0;
    }

    int max = 0;
    for(int i = n - 1; i > -1; i--)
    {
        if(i + a[i] > n - 1)
        {
            b[i] = a[i];
            if(b[i] > max)
            {
                max = b[i];
            }
        }
        else
        {
            b[i] = a[i] + b[i + a[i]];
            if(b[i] > max)
            {
                max = b[i];
            }
        }

    }

    cout << max << "\n";
}


int main()
{
    std::ios_base::sync_with_stdio(false);
    cin.tie(0);

    int t;
    cin >> t;

    while(t--)
    {
        solve();
    }

    return 0;
}


