#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e9 + 7;
int a[200002];
int dp[200002][2];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int Q;
  cin >> Q;
  while (Q--) {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      dp[i][0] = MAX, dp[i][1] = MAX;
    }
    dp[n][0] = MAX;
    dp[n][1] = MAX;
    dp[0][0] = 0;
    dp[0][1] = MAX;
    for (int i = 1; i <= n; i++) {
      dp[i][1] = min(dp[i][1], dp[i - 1][0] + a[i - 1]);
      if (i >= 2) dp[i][1] = min(dp[i][1], dp[i - 2][0] + a[i - 1] + a[i - 2]);
      dp[i][0] = min(dp[i][0], dp[i - 1][1]);
      if (i >= 2) dp[i][0] = min(dp[i][0], dp[i - 2][1]);
    }
    cout << min(dp[n][0], dp[n][1]) << "\n";
  }
}
