#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, a[200000], rui[200000], sao[200000];
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    rui[1] = a[1];
    sao[1] = 1e9;
    rui[2] = a[1] + a[2];
    sao[2] = a[1];
    rui[3] = a[1] + a[3];
    sao[3] = a[1];
    if (n < 4)
      cout << a[1] << endl;
    else {
      for (int i = 4; i <= n; i++) {
        if ((sao[i - 2] + a[i] + a[i - 1]) < (sao[i - 1] + a[i]))
          rui[i] = sao[i - 2] + a[i] + a[i - 1];
        else
          rui[i] = sao[i - 1] + a[i];
        if (rui[i - 2] < rui[i - 1])
          sao[i] = rui[i - 2];
        else
          sao[i] = rui[i - 1];
      }
      if (sao[n] > rui[n])
        cout << rui[n] << endl;
      else
        cout << sao[n] << endl;
    }
  }
  return 0;
}
