#include <bits/stdc++.h>
using namespace std;
using pii = pair<long long, long long>;
struct EndSet {
  set<long long> points;
  pii seg = {1, 0};
  long long cbase = 0, cdir = 1;
  void setFree(long long mx) {
    points.clear(), cbase = 0, cdir = 1;
    seg = {1, mx};
  }
  void setPush(long long x) {
    setFree(0);
    points.insert(x);
  }
  void rotate(long long balance) {
    cbase = balance - cbase;
    cdir = -cdir;
    seg = {balance - seg.second, balance - seg.first};
  }
  long long tr(long long x) { return cbase + cdir * x; }
  long long anti(long long x) { return cdir * (x - cbase); }
  bool in(long long x) {
    if (points.count(anti(x))) return true;
    return (seg.first <= x && x <= seg.second);
  }
  void push(long long x) { points.insert(anti(x)); }
  void popBelow(long long x) {
    seg.second = min(seg.second, x);
    auto nextIt = [&] {
      return (cdir == 1 ? prev(points.end()) : points.begin());
    };
    while (!points.empty() && tr(*nextIt()) > x) points.erase(nextIt());
  }
  bool empty() { return points.empty() && seg.first > seg.second; }
};
void solve() {
  long long n;
  cin >> n;
  EndSet util;
  long long curAns = 0;
  for (long long i = 0; i < n; ++i) {
    long long x;
    cin >> x;
    util.popBelow(x - 1);
    if (x % 2 == 0 && util.in(x / 2)) {
      curAns += 2;
      util.setPush(x / 2);
    } else if (util.empty()) {
      if (x % 2 == 0)
        curAns += 1, util.setPush(x / 2);
      else
        util.setFree(x - 1);
    } else {
      curAns += 1;
      if (x % 2 == 0) util.push(x / 2);
    }
    util.rotate(x);
  }
  cout << 2 * n - curAns << "\n";
}
signed main() {
  ios::sync_with_stdio(false), cin.tie(0);
  long long nbTests;
  cin >> nbTests;
  for (long long iTest = 0; iTest < nbTests; ++iTest) {
    solve();
  }
}
