#include <bits/stdc++.h>
using namespace std;
bool b[200005];
int d[200005][2];
int main() {
  int t, n;
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> b[i];
    d[n][0] = d[n][1] = 0;
    d[n - 1][0] = b[n - 1], d[n - 1][1] = 0;
    for (int i = n - 2; i >= 0; i--) {
      d[i][0] = min(b[i] + d[i + 1][1], b[i] + b[i + 1] + d[i + 2][1]);
      d[i][1] = min(d[i + 1][0], d[i + 2][0]);
    }
    cout << d[0][0] << "\n";
  }
}
