use a dp approach in which if there are many occurence of the target element try by all the elements so as to maximise k,#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

#define loop(i, l, n) for (decltype(n) i = l; i < n; i++)
#define mk make_pair
#define pb push_back
#define print(k) cout << k << "\n"
#define MOD 1000000007

// Binary search to find the last occurrence of a requested number
int finn(const vector<pii>& v1, int target) {
    int left = 0, right = v1.size() - 1;
    int result = -1;  // Default to -1 if target is not found
    
    while (left <= right) {
        int mid = left + (right - left) / 2;
        
        if (v1[mid].first == target) {
            result = mid;     // Update result with the current index
            left = mid + 1;   // Move right to find the last occurrence
        } 
        else if (v1[mid].first < target) {
            left = mid + 1;   // Search right
        } 
        else {
            right = mid - 1;  // Search left
        }
    }
    
    return result;
}

// Binary search to find the last occurrence of a requested number
// and return the index where v1[i].second is maximum
int find(const vector<pii>& v1, int target) {
    int left = 0, right = v1.size() - 1;
    int result = -1;  // Default to -1 if target is not found
    int maxSecond = -1; // Track maximum of v1[i].second for target occurrences
    
    while (left <= right) {
        int mid = left + (right - left) / 2;
        
        if (v1[mid].first == target) {
            // Check if this index has the maximum `second` value found so far
            if (v1[mid].second > maxSecond) {
                maxSecond = v1[mid].second;
                result = mid;
            }
            left = mid + 1;   // Continue searching to the right to find last occurrence
        } 
        else if (v1[mid].first < target) {
            left = mid + 1;   // Search right
        } 
        else {
            right = mid - 1;  // Search left
        }
    }
    
    return result;
}

// Binary search to find the last occurrence of a requested number
int fin(const vector<pii>& v1, int target) {
    int left = 0, right = v1.size() - 1;
    int result = -1;  // Default to -1 if target is not found
    
    while (left <= right) {
        int mid = left + (right - left) / 2;
        
        if (v1[mid].first == target) {
            result = mid;     // Update result with the current index
            left = mid + 1;   // Move right to find the last occurrence
        } 
        else if (v1[mid].first < target) {
            left = mid + 1;   // Search right
        } 
        else {
            right = mid - 1;  // Search left
        }
    }
    
    return result;
}



void solve() {
    int n;
    cin >> n;
    
    vi v(n);
    vector<pii> v1(n);
    
    loop(i, 0, n) {
        cin >> v[i];
        v1[i] = mk(v[i] + i, i);
    }
    
    // Sort v1 based on the first element of each pair
    sort(v1.begin(), v1.end());
    
    int k = n;
    int last;

    // Iteratively find the last index of the requested value in v1
    while (true) {
        last = fin(v1, k);
        // cout<<last<<" ";
        if (last == -1 || v1[last].second == 0) {
            break; // Exit if the target is not found
        }
        k += v1[last].second; // Update k by adding the second element at the last index found
    }
    
    cout << k << "\n";
}

int main() {
    #ifdef ONLINEJUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    int t = 1;
    cin >> t;
    while (t--) {
        solve();
    }
}