#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long arr[n];
    for (long long i = 0; i < n; i++) cin >> arr[i];
    long long dp[n][2];
    dp[n - 1][0] = arr[n - 1];
    dp[n - 1][1] = 0;
    for (long long i = n - 2; i >= 0; i--) {
      if (i + 2 < n) {
        dp[i][0] =
            min(dp[i + 2][1] + arr[i] + arr[i + 1], dp[i + 1][1] + arr[i]);
        dp[i][1] = min(dp[i + 1][0], dp[i + 2][0]);
      } else {
        dp[i][0] = dp[i + 1][1] + arr[i];
        dp[i][1] = min(dp[i + 1][0], dp[i + 1][1]);
      }
    }
    cout << dp[0][0] << endl;
  }
}
