#include <set>
#include <cstdio>
#include <cstring>

#define REP(i,n) for(int i=0; i<(int)(n); i++)

inline int getInt(){ int s; scanf("%d", &s); return s; }

using namespace std;

int n;
int e[80];
int memo[80][100][100];

int solve(int pos, int prev, int now){
  if(pos == n - 1) return now;
  if(prev < 100 && now < 100)
    if(memo[pos][prev][now] != -1) return memo[pos][prev][now];

  int ret = 0;

  if(now > 0){
    // hit
    ret = max(ret, solve(pos + 1, now - 1, e[pos + 1] + prev));
  }

  ret = max(ret, solve(pos + 1, now, e[pos + 1]));

  return memo[pos][prev][now] = ret;
}

int main(){
  int cc = getInt();

  while(cc --> 0){
    n = getInt();
    REP(i,n) e[i] = getInt();
    memset(memo, -1, sizeof(memo));

    if(n >= 3)
      printf("%d\n", solve(1, e[0], e[1]));
    else
      printf("%d\n", e[n - 1]);
  }

  return 0;
}