#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, i, j, k, l, t;
  cin >> t;
  while (t--) {
    cin >> n;
    vector<int> a(n);
    for (i = 0; i < n; i++) {
      cin >> a[i];
    }
    k = 1;
    long long total = 0;
    for (i = 0; i < n; i++) {
      if (k % 2 != 0) {
        total += a[i];
        if (a[i + 1] == 0) {
          while (i + 1 < n && a[i + 1] == 0) {
            i++;
          }
        }
      } else {
        if (a[i + 1] == 1) i++;
      }
      k++;
    }
    cout << total << endl;
  }
}
