#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
int dp[200005][2], a[200005];
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
    }
    memset(dp, inf, sizeof(dp));
    dp[1][0] = a[1];
    dp[2][0] = dp[1][0] + a[2];
    dp[2][1] = dp[1][0];
    for (int i = 3; i <= n; i++) {
      dp[i][0] = min(dp[i - 1][1] + a[i], dp[i - 2][1] + a[i - 1] + a[i]);
      dp[i][1] = min(dp[i - 1][0], dp[i - 2][0]);
    }
    cout << min(dp[n][0], dp[n][1]) << endl;
  }
  return 0;
}
