#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
using namespace std;
const long long int INF = 2e18;
const int inf = 2e9;
const int mod1 = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < a.size(); i++) cin >> a[i];
    ;
    vector<vector<int>> dp(n, vector<int>(2, 1e9));
    dp[0][0] = (a[0]);
    if (n > 1) {
      dp[1][0] = dp[0][0] + a[1];
      dp[1][1] = dp[0][0];
    }
    for (int i = 2; i < n; i++) {
      dp[i][0] = min(dp[i - 2][1] + a[i - 1], dp[i - 1][1]) + a[i];
      dp[i][1] = min(dp[i - 2][0], dp[i - 1][0]);
    }
    cout << min(dp[n - 1][0], dp[n - 1][1]) << "\n";
  }
  return 0;
}
