#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n, dp[N][2], a[N];
int main() {
  int test = 0;
  cin >> test;
  while (test--) {
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    dp[1][0] = n;
    dp[1][1] = dp[2][0] = a[1];
    dp[2][1] = a[1] + a[2];
    for (int i = 3; i <= n; i++) {
      dp[i][0] = min(dp[i - 1][1], dp[i - 2][1]);
      dp[i][1] = min(dp[i - 1][0] + a[i], dp[i - 2][0] + a[i] + a[i - 1]);
    }
    cout << min(dp[n][0], dp[n][1]) << endl;
  }
  return 0;
}
