#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int asd = 0; asd < t; asd++) {
    int n;
    cin >> n;
    vector<bool> v;
    for (int i = 0; i < n; i++) {
      bool a;
      cin >> a;
      v.push_back(a);
    }
    if (n == 1) {
      cout << v[0] << endl;
    } else {
      vector<int> fr = {0, int(v[0]), int(v[0]) + int(v[1])},
                  me = {200000, 200000, fr[1]};
      for (int i = 3; i <= n; i++) {
        int mn = 200000;
        for (int j = i - 1; j >= 0 && j >= i - 2; j--) {
          mn = min(mn, fr[j]);
        }
        me.push_back(mn);
        mn = 200000;
        int pl = 0;
        for (int j = i - 1; j >= 0 && j >= i - 2; j--) {
          if (v[j]) pl++;
          mn = min(mn, me[j] + pl);
        }
        fr.push_back(mn);
      }
      cout << min(me[n], fr[n]) << endl;
    }
  }
  return 0;
}
