include
include <bits/stdc++.h>
define ll long long
define pb push_back
define s second
define f first
define sort(x) sort(x.begin(),x.end());
using namespace std; void bruh(){ ll n; cin >> n; vector a(n); for (ll i = 0;i<n;i++){ cin >> a[i]; } vector test = a; for (ll i = 1;i<n;i+=2){ if(i==n-1){ ll op = max(0LL,a[i-1]-a[i]); a[i-1]-=op; }else{ ll d = a[i-1]+a[i+1]; if(d>a[i]){ ll ost = d-a[i]; a[i+1]-=(min(a[i+1],ost)); ll ok = a[i-1]+a[i+1]; if(ok>a[i]){ a[i-1]-=ok-a[i]; } }} } ll sm = 0; for (ll i = 0;i<n;i++){ if(i%2==0){ sm+=test[i]-a[i]; } // cout << a[i] << " "; } //cout << endl; cout << sm << endl; }
int main() { ll t; cin >> t; while (t--){ bruh(); } }



