#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 50;
int T, n, a[N];
set<pair<long long, long long> > S;
void Main() {
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  int zero = 0, two = -1;
  long long k = 1, b = 0;
  S.clear();
  for (int i = 1, x; i <= n; i++) {
    x = a[i];
    if (two != -1) {
      zero = zero + 2;
      S.clear();
      k = 1, b = 0;
      if (x - two > 0) S.insert(pair<long long, long long>(x - two, x - two));
    } else if (S.size()) {
      if (k == 1) {
        while (S.size() && (--S.end())->first + b >= x) S.erase(--S.end());
        if (S.size() && (--S.end())->second + b >= x) {
          auto z = --S.end();
          long long l = z->first;
          long long r = x - 1 - b;
          S.erase(z), S.insert(pair<long long, long long>(l, r));
        }
      } else {
        while (S.size() && b - S.begin()->second >= x) S.erase(S.begin());
        if (S.size() && b - S.begin()->first >= x) {
          auto z = S.begin();
          long long l = z->second;
          long long r = b - (x - 1);
          S.erase(z), S.insert(pair<long long, long long>(r, l));
        }
      }
      zero = zero + 1, k = -k, b = x - b;
    } else {
      if (i > 1) S.insert(pair<long long, long long>(1, min(a[i - 1], x) - 1));
      k = -1, b = x;
    }
    two = -1;
    if (x & 1) continue;
    long long p = k * ((x >> 1) - b);
    auto w = S.lower_bound(pair<long long, long long>(p + 1, p + 1));
    bool ok = false;
    if (S.size() && w != S.begin()) {
      --w;
      if (w->first <= p && p <= w->second) {
        long long l = w->first, r = w->second;
        S.erase(w);
        if (l < p) S.insert(pair<long long, long long>(l, p - 1));
        if (p < r) S.insert(pair<long long, long long>(p + 1, r));
        two = p * k + b, ok = true;
      }
    }
    if (!ok) S.insert(pair<long long, long long>(p, p));
  }
  if (two > 0)
    cout << n + n - zero - 2 << '\n';
  else if (S.size())
    cout << n + n - zero - 1 << '\n';
  else
    cout << n + n - zero << '\n';
}
int main() {
  cin >> T;
  while (T--) Main();
  return 0;
}
