#include <bits/stdc++.h>
using namespace std;
set<pair<long long, long long> > st;
long long v, c;
void pop() {
  if (v == 1) {
    while (!st.empty()) {
      set<pair<long long, long long> >::iterator it = st.begin();
      if ((it->second) + c > 0)
        break;
      else {
        pair<long long, long long> t = *it;
        st.erase(it);
        if (t.first + c > 0) {
          st.insert(pair<long long, long long>(t.first, 1 - c));
          break;
        }
      }
    }
  } else {
    while (!st.empty()) {
      set<pair<long long, long long> >::iterator it = st.end();
      it--;
      if (-(it->first) + c > 0)
        break;
      else {
        pair<long long, long long> t = *it;
        st.erase(it);
        if (-t.second + c > 0) {
          st.insert(pair<long long, long long>(c - 1, t.second));
          break;
        }
      }
    }
  }
}
bool find(int k) {
  if (st.empty()) return 0;
  if (v == 1) {
    set<pair<long long, long long> >::iterator it = st.lower_bound(
        pair<long long, long long>(k - c, -0x3f3f3f3f3f3f3f3fLL));
    if (it != st.end() && (it->second) <= k - c)
      return 1;
    else
      return 0;
  } else {
    set<pair<long long, long long> >::iterator it = st.lower_bound(
        pair<long long, long long>(c - k, -0x3f3f3f3f3f3f3f3fLL));
    if (it != st.end() && (it->second) <= c - k)
      return 1;
    else
      return 0;
  }
}
void insert(int k) {
  if (v == 1)
    st.insert(pair<long long, long long>(k - c, k - c));
  else
    st.insert(pair<long long, long long>(c - k, c - k));
}
int num[500005];
int main() {
  int cases;
  scanf("%d", &cases);
  for (; cases; cases--) {
    st.clear();
    v = 1;
    c = 0;
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &num[i]);
    int ans = 2 * n;
    if (num[1] % 2 == 0) {
      ans--;
      st.insert(pair<long long, long long>(num[1] >> 1, num[1] >> 1));
    } else
      st.insert(pair<long long, long long>(num[1] - 1, 1));
    for (int i = 2; i <= n; i++) {
      v = -v;
      c = num[i] - c;
      pop();
      if (num[i] % 2 == 0) {
        if (find(num[i] >> 1)) {
          ans -= 2;
          v = 1;
          c = 0;
          st.clear();
          st.insert(pair<long long, long long>(num[i] >> 1, num[i] >> 1));
        } else {
          ans -= 1;
          insert(num[i] >> 1);
        }
      } else if (!st.empty())
        ans -= 1;
      else {
        v = 1;
        c = 0;
        st.clear();
        st.insert(pair<long long, long long>(num[i] - 1, 1));
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
