#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using u64 = uint64_t;
using pi64 = pair<i64, i64>;
constexpr i64 MAXN = 3 * 100 * 1000 + 5LL;
constexpr i64 MOD = 1000000007LL;
constexpr i64 INF64 = MOD * MOD;
enum who_t {
  kWe = 0,
  kThey = 1,
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  const unsigned seed = chrono::system_clock::now().time_since_epoch().count();
  mt19937 gen(seed);
  i64 T;
  cin >> T;
  ;
  for (; T-- > 0;) {
    i64 N;
    cin >> N;
    ;
    vector<i64> A(N);
    {
      for (i64 i = 0; i < N; ++i) {
        cin >> A[i];
      }
    };
    vector<vector<i64>> dp(N + 1, vector<i64>(2, INF64));
    dp[0][kWe] = 0;
    dp[1][kThey] = A[0];
    for (i64 i = 2; i <= N; ++i) {
      dp[i][kWe] = min(dp[i - 1][kThey], dp[i - 2][kThey]);
      dp[i][kThey] = min(dp[i - 1][kWe], dp[i - 2][kWe] + A[i - 2]) + A[i - 1];
      ;
    }
    cout << *min_element(dp.back().begin(), dp.back().end()) << "\n";
  }
  return 0;
}
