#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> tower(n);
    for (auto &it : tower) cin >> it;
    vector<vector<pair<int, int>>> dp(n, vector<pair<int, int>>(2, {0, 0}));
    dp[0][0] = {tower[0], 1};
    dp[0][1] = {1e9, 2};
    for (int i = 1; i < n; i++) {
      if (dp[i - 1][0].first == dp[i - 1][1].first) {
        dp[i][0] = {dp[i - 1][1].first + tower[i], 1};
      } else if (dp[i - 1][0].first < dp[i - 1][1].first &&
                 dp[i - 1][0].second != 2) {
        dp[i][0] = {dp[i - 1][0].first + tower[i], 2};
      } else {
        dp[i][0] = {dp[i - 1][1].first + tower[i], 1};
      }
      if (dp[i - 1][1].first == dp[i - 1][0].first) {
        dp[i][1] = {dp[i - 1][0].first, 1};
      } else if (dp[i - 1][1].first < dp[i - 1][0].first &&
                 dp[i - 1][1].second != 2) {
        dp[i][1] = {dp[i - 1][1].first, 2};
      } else {
        dp[i][1] = {dp[i - 1][0].first, 1};
      }
    }
    cout << min(dp[n - 1][0].first, dp[n - 1][1].first) << endl;
  }
  return 0;
}
