#include <bits/stdc++.h>
using namespace std;
const long long dx[4] = {-1, 1, 0, 0};
const long long dy[4] = {0, 0, -1, 1};
long long dp[200005][2];
bool a[200005];
signed main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    for (long long i = 0; i < n; i++) cin >> a[i];
    for (long long i = n - 1; i >= 0; i--) {
      dp[i][0] = min(dp[i + 1][1], dp[i + 2][1]);
      dp[i][1] = a[i] + min(dp[i + 1][0], a[i + 1] + dp[i + 2][0]);
    }
    cout << dp[0][1] << '\n';
    for (long long i = 0; i < n; i++) dp[i][0] = dp[i][1] = a[i] = 0;
  }
  return 0;
}
