#include <bits/stdc++.h>
using std::max;
using std::min;
const int inf = 0x3f3f3f3f, Inf = 0x7fffffff;
const long long INF = 0x3f3f3f3f3f3f3f3f;
std::mt19937 rnd(std::chrono::steady_clock::now().time_since_epoch().count());
template <typename _Tp>
_Tp gcd(const _Tp &a, const _Tp &b) {
  return (!b) ? a : gcd(b, a % b);
}
template <typename _Tp>
inline _Tp abs(const _Tp &a) {
  return a >= 0 ? a : -a;
}
template <typename _Tp>
inline void chmax(_Tp &a, const _Tp &b) {
  (a < b) && (a = b);
}
template <typename _Tp>
inline void chmin(_Tp &a, const _Tp &b) {
  (b < a) && (a = b);
}
template <typename _Tp>
inline void read(_Tp &x) {
  char ch(getchar());
  bool f(false);
  while (!isdigit(ch)) f |= ch == 45, ch = getchar();
  x = ch & 15, ch = getchar();
  while (isdigit(ch)) x = (((x << 2) + x) << 1) + (ch & 15), ch = getchar();
  f && (x = -x);
}
template <typename _Tp, typename... Args>
inline void read(_Tp &t, Args &...args) {
  read(t);
  read(args...);
}
inline int read_str(char *s) {
  char ch(getchar());
  while (ch == ' ' || ch == '\r' || ch == '\n') ch = getchar();
  char *tar = s;
  *tar = ch, ch = getchar();
  while (ch != ' ' && ch != '\r' && ch != '\n' && ch != EOF)
    *(++tar) = ch, ch = getchar();
  return tar - s + 1;
}
const int N = 500005;
long long val, k, b;
std::set<long long> S;
long long a[N];
void MAIN() {
  long long n;
  read(n);
  for (long long i = 1; i <= n; ++i) read(a[i]);
  S.clear();
  k = 1, b = 0, val = 1;
  long long L = 1, R = 1e9;
  for (long long i = 1; i <= n; ++i) {
    k = -k, b = a[i] - b;
    L = a[i] - L, R = a[i] - R;
    std::swap(L, R);
    chmax(L, 1LL), chmin(R, a[i] - 1LL);
    long long A = val + 1;
    if (!(a[i] & 1)) {
      long long cur = ((L <= (a[i] >> 1) && (a[i] >> 1) <= R) ||
                       S.find(((a[i] >> 1) - b) * k) != S.end())
                          ? val
                          : val + 1;
      if (cur == A)
        S.insert(((a[i] >> 1) - b) * k);
      else if (cur < A) {
        A = cur;
        L = 1, R = 0;
        k = 1, b = 0;
        S = {a[i] >> 1};
      } else
        assert(0);
    }
    while (!S.empty() && *S.begin() * k + b <= 0) S.erase(S.begin());
    while (!S.empty() && *S.begin() * k + b >= a[i]) S.erase(S.begin());
    while (!S.empty() && *S.rbegin() * k + b <= 0) S.erase(--S.end());
    while (!S.empty() && *S.rbegin() * k + b >= a[i]) S.erase(--S.end());
    chmax(L, 1LL), chmin(R, a[i] - 1LL);
    val = A;
    if (S.empty() && L > R) {
      L = 1, R = a[i] - 1;
      ++val;
    }
  }
  printf("%lld\n", val);
}
signed main() {
  long long _;
  read(_);
  while (_--) MAIN();
  return 0;
}
