#include <bits/stdc++.h>
using namespace std;
const long long INF = 0x3f3f3f3f;
template <typename _T>
_T Fabs(_T x) {
  return x < 0 ? -x : x;
}
template <typename _T>
void read(_T &x) {
  _T f = 1;
  x = 0;
  char s = getchar();
  while (s > '9' || s < '0') {
    if (s == '-') f = -1;
    s = getchar();
  }
  while ('0' <= s && s <= '9') {
    x = (x << 3) + (x << 1) + (s ^ 48);
    s = getchar();
  }
  x *= f;
}
long long t, n, zero, two, a[500005];
set<pair<long long, long long> > one;
signed main() {
  read(t);
  while (t--) {
    read(n);
    long long shifter = 0, sign = 1;
    two = -1;
    for (long long i = 1; i <= n; i++) read(a[i]);
    for (long long i = 1; i <= n; i++) {
      long long x = a[i];
      if (two ^ -1) {
        zero += 2;
        one.clear();
        sign = 1;
        shifter = 0;
        if (x > two) one.insert(make_pair(x - two, x - two));
      } else if (!one.empty()) {
        if (sign > 0) {
          while (!one.empty() && shifter + one.rbegin()->first >= x)
            one.erase(*one.rbegin());
          if (!one.empty() && shifter + one.rbegin()->second >= x) {
            long long t = one.rbegin()->first;
            one.erase(*one.rbegin());
            one.insert(make_pair(t, x - shifter - 1));
          }
        } else {
          while (!one.empty() && shifter - one.begin()->second >= x)
            one.erase(*one.begin());
          if (!one.empty() && shifter - one.begin()->first >= x) {
            long long t = one.begin()->second;
            one.erase(*one.begin());
            one.insert(make_pair(shifter + 1 - x, t));
          }
        }
        zero++;
        sign *= -1;
        shifter = x - shifter;
      } else {
        shifter = x;
        sign = -1;
        if (i ^ 1) one.insert(make_pair(1, min(a[i - 1], x) - 1));
      }
      two = -1;
      if (x & 1) continue;
      long long c = x / 2, t = sign * (c - shifter);
      bool flag = 0;
      auto it = one.lower_bound(make_pair(t + 1, t + 1));
      if (it != one.begin()) {
        it--;
        if (it->first <= t && t <= it->second) {
          long long t1 = it->first, t2 = it->second;
          one.erase(it);
          if (t1 ^ t) one.insert(make_pair(t1, t - 1));
          if (t2 ^ t) one.insert(make_pair(t + 1, t2));
          two = c;
          flag = 1;
        }
      }
      if (!flag) one.insert(make_pair(t, t));
    }
    if (two != -1)
      printf("%d\n", 2 * n - zero - 2);
    else if (!one.empty())
      printf("%d\n", 2 * n - zero - 1);
    else
      printf("%d\n", 2 * n - zero);
    one.clear();
    zero = two = 0;
  }
  return 0;
}
