#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops", "omit-frame-pointer", "inline")
#pragma GCC option("arch=native", "tune=native", "no-zero-upper")
#pragma GCC target("avx2")
using namespace std;
template <typename T>
void maxtt(T& t1, T t2) {
  t1 = max(t1, t2);
}
template <typename T>
void mintt(T& t1, T t2) {
  t1 = min(t1, t2);
}
bool debug = 0;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
string direc = "RDLU";
const long long MOD2 = (long long)998244353 * (long long)998244353;
long long ln, lk, lm;
void etp(bool f = 0) {
  puts(f ? "YES" : "NO");
  exit(0);
}
void addmod(int& x, int y, int mod = 998244353) {
  x += y;
  if (x >= mod) x -= mod;
  if (x < 0) x += mod;
  assert(x >= 0 && x < mod);
}
void et(int x = -1) {
  printf("%d\n", x);
  exit(0);
}
long long fastPow(long long x, long long y, int mod = 998244353) {
  long long ans = 1;
  while (y > 0) {
    if (y & 1) ans = (x * ans) % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return ans;
}
long long gcd1(long long x, long long y) { return y ? gcd1(y, x % y) : x; }
int a[(500135)];
void fmain(int tid) {
  scanf("%d", &n);
  for (int(i) = 1; (i) <= (int)(n); (i)++) scanf("%d", a + i);
  int zero = 0, two = -1, sg = 1;
  set<pair<long long, long long> > one;
  long long sft = 0;
  for (int(i) = 1; (i) <= (int)(n); (i)++) {
    int x = a[i];
    if (two != -1) {
      zero += 2;
      one.clear();
      sft = 0;
      sg = 1;
      if (a[i] - two > 0) one.insert({a[i] - two, a[i] - two});
    } else if (!one.empty()) {
      if (sg == 1) {
        while (!one.empty() && sft + one.rbegin()->first >= x) {
          one.erase(*one.rbegin());
        }
        if (!one.empty() && sft + one.rbegin()->second >= x) {
          long long S = one.rbegin()->first;
          one.erase(*one.rbegin());
          one.insert({S, x - 1 - sft});
        }
      } else {
        while (!one.empty() && sft - one.begin()->second >= x) {
          one.erase(*one.begin());
        }
        if (!one.empty() && sft - one.begin()->first >= x) {
          long long S = one.begin()->second;
          one.erase(*one.begin());
          one.insert({sft - (x - 1), S});
        }
      }
      zero++;
      sg *= -1;
      sft = x - sft;
    } else {
      sft = x;
      sg = -1;
      if (i - 1) one.insert({1, min(a[i - 1], x) - 1});
    }
    two = -1;
    if (x & 1) continue;
    int hf = x >> 1;
    long long T = (hf - sft) * sg;
    auto it = one.lower_bound({T + 1, T + 1});
    bool fg = 0;
    if (it != one.begin()) {
      it--;
      if (it->first <= T && T <= it->second) {
        long long L = it->first, R = it->second;
        one.erase(it);
        if (L != T) one.insert({L, T - 1});
        if (R != T) one.insert({T + 1, R});
        two = hf;
        fg = 1;
      }
    }
    if (!fg) one.insert({T, T});
  }
  int ans = n * 2 - zero;
  if (two != -1)
    ans -= 2;
  else if (!one.empty())
    ans--;
  printf("%d\n", ans);
}
int main() {
  int t = 1;
  scanf("%d", &t);
  for (int(i) = 1; (i) <= (int)(t); (i)++) {
    fmain(i);
  }
  return 0;
}
