#include <bits/stdc++.h>
using namespace std;
const int inf = 1000000000;
long long mod = 1000000007LL;
long long mod2 = 998244353LL;
int t, n;
int a[200005];
int dp[200005][2];
int main() {
  cin >> t;
  for (int cas = 1; cas <= t; ++cas) {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
      scanf("%d", &a[i]);
    }
    for (int i = 0; i <= n; ++i) {
      for (int j = 0; j < 2; ++j) {
        dp[i][j] = inf;
      }
    }
    dp[0][0] = 0;
    for (int i = 0; i < n; ++i) {
      if (dp[i][0] < inf) {
        if (a[i + 1]) {
          dp[i + 1][1] = min(dp[i + 1][1], dp[i][0] + 1);
        } else {
          dp[i + 1][1] = min(dp[i + 1][1], dp[i][0]);
        }
        if (i + 2 <= n) {
          int cnt = a[i + 1] + a[i + 2];
          dp[i + 2][1] = min(dp[i + 2][1], dp[i][0] + cnt);
        }
      }
      if (dp[i][1] < inf) {
        dp[i + 1][0] = min(dp[i + 1][0], dp[i][1]);
        if (i + 2 <= n) {
          dp[i + 2][0] = min(dp[i + 2][0], dp[i][1]);
        }
      }
    }
    int res = min(dp[n][0], dp[n][1]);
    printf("%d\n", res);
  }
  return 0;
}
