#include<bits/stdc++.h>
using namespace std;
long long t,n;
const int Nmax=100000+5;
long long a[Nmax];
long long dp[Nmax];
long long ans(int i){
if(i>=n)
return 0;
long long x,y,z;
if(i<n){
x=a[i];
if(i+2<n){
if(dp[i+2]==-1)
dp[i+2]=ans(i+2);
x+=dp[i+2];
}
}
if(i+1<n){
y=a[i]+a[i+1];
if(i+4<n){
if(dp[i+4]==-1)
dp[i+4]=ans(i+4);
y+=dp[i+4];
}
}
if(i+2<n){
z=a[i]+a[i+1]+a[i+2];
if(i+6<n){
if(dp[i+6]==-1)
dp[i+6]=ans(i+6);
z+=dp[i+6];
}
}
return dp[i]=max(x,max(y,z));
}
int main(){
cin>>t;
while(t--){
cin>>n;
for(int i=0;i<n;i++)
cin>>a[i];
memset(dp,-1,sizeof dp);
cout<<ans(0)<<endl;
}
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKbG9uZyBsb25nIHQsbjsKY29uc3QgaW50IE5tYXg9MTAwMDAwKzU7CmxvbmcgbG9uZyBhW05tYXhdOwpsb25nIGxvbmcgZHBbTm1heF07CmxvbmcgbG9uZyBhbnMoaW50IGkpewogICAgaWYoaT49bikKICAgICAgICByZXR1cm4gMDsKICAgIGxvbmcgbG9uZyB4LHksejsKICAgIGlmKGk8bil7CiAgICAgICAgeD1hW2ldOwogICAgICAgIGlmKGkrMjxuKXsKICAgICAgICAgICAgaWYoZHBbaSsyXT09LTEpCiAgICAgICAgICAgICAgICBkcFtpKzJdPWFucyhpKzIpOwogICAgICAgICAgICB4Kz1kcFtpKzJdOwogICAgICAgIH0KICAgIH0KICAgIGlmKGkrMTxuKXsKICAgICAgICB5PWFbaV0rYVtpKzFdOwogICAgICAgICBpZihpKzQ8bil7CiAgICAgICAgICAgIGlmKGRwW2krNF09PS0xKQogICAgICAgICAgICAgICAgZHBbaSs0XT1hbnMoaSs0KTsKICAgICAgICAgICAgeSs9ZHBbaSs0XTsKICAgICAgICB9CiAgICB9CiAgICBpZihpKzI8bil7CiAgICAgICAgej1hW2ldK2FbaSsxXSthW2krMl07CiAgICAgICAgIGlmKGkrNjxuKXsKICAgICAgICAgICAgaWYoZHBbaSs2XT09LTEpCiAgICAgICAgICAgICAgICBkcFtpKzZdPWFucyhpKzYpOwogICAgICAgICAgICB6Kz1kcFtpKzZdOwogICAgICAgIH0KICAgIH0KICAgIHJldHVybiBkcFtpXT1tYXgoeCxtYXgoeSx6KSk7Cn0KCmludCBtYWluKCl7CiAgICBjaW4+PnQ7CiAgICB3aGlsZSh0LS0pewogICAgICAgIGNpbj4+bjsKICAgICAgICBmb3IoaW50IGk9MDtpPG47aSsrKQogICAgICAgICAgICBjaW4+PmFbaV07CiAgICAgICAgbWVtc2V0KGRwLC0xLHNpemVvZiBkcCk7CiAgICAgICAgY291dDw8YW5zKDApPDxlbmRsOwogICAgfQp9