#include <bits/stdc++.h>
using namespace std;
const long long int INF = 2000LL * 1000 * 1000 * 1000000000;
set<pair<long long int, long long int> > segs;
long long int sign, bias;
void restart() {
  segs.clear();
  sign = +1;
  bias = 0;
  return;
}
long long int convertb(long long int val) { return (val - bias) * sign; }
pair<long long int, long long int> convertb(
    pair<long long int, long long int> seg) {
  seg.first = convertb(seg.first);
  seg.second = convertb(seg.second);
  if (seg.first > seg.second) swap(seg.first, seg.second);
  return seg;
}
void add(pair<long long int, long long int> seg) {
  seg = convertb(seg);
  if (seg.first == seg.second) {
    auto it = segs.lower_bound(make_pair(seg.first, -INF));
    if (it != segs.begin()) {
      it--;
      if (it->second >= seg.first) return;
    }
  }
  segs.insert(seg);
}
void tighten(pair<long long int, long long int> seg) {
  seg = convertb(seg);
  while (((int)(segs).size()) and segs.begin()->first < seg.first) {
    pair<long long int, long long int> badseg = *segs.begin();
    segs.erase(segs.begin());
    (badseg.first) = max((badseg.first), (seg.first));
    if (badseg.first <= badseg.second) segs.insert(badseg);
  }
  while (((int)(segs).size()) and segs.rbegin()->second > seg.second) {
    pair<long long int, long long int> badseg = *segs.rbegin();
    segs.erase(badseg);
    (badseg.second) = min((badseg.second), (seg.second));
    if (badseg.first <= badseg.second) segs.insert(badseg);
  }
}
bool can_connect(pair<long long int, long long int> seg) {
  if (((int)(segs).size()) == 0) return false;
  seg = convertb(seg);
  if (seg.second < segs.begin()->first or seg.first > segs.rbegin()->second)
    return false;
  auto it = segs.lower_bound(make_pair(seg.first, -INF));
  if (it != segs.end() and it->first <= seg.second) return true;
  if (it == segs.begin()) return false;
  it--;
  return it->second >= seg.first;
}
int solve() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  int dp[n + 1];
  dp[n] = 0;
  restart();
  for (int i = n - 1; i >= 0; i--) {
    if (a[i] % 2 == 0) {
      if (can_connect(make_pair(a[i] / 2, a[i] / 2))) {
        restart();
        dp[i] = dp[i + 1] + 2;
      } else if (can_connect(make_pair(1, a[i] - 1))) {
        dp[i] = dp[i + 1] + 1;
        tighten(make_pair(1, a[i] - 1));
      } else {
        restart();
        dp[i] = dp[i + 1] + 1;
      }
      add(make_pair(a[i] / 2, a[i] / 2));
    } else if (can_connect(make_pair(1, a[i] - 1))) {
      dp[i] = dp[i + 1] + 1;
      tighten(make_pair(1, a[i] - 1));
    } else {
      dp[i] = dp[i + 1];
      restart();
      add(make_pair(1, a[i] - 1));
    }
    sign = -sign;
    bias = a[i] - bias;
  }
  cerr << '\n';
  cout << 2 * n - dp[0] << endl;
  return 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int q;
  cin >> q;
  while (q--) solve();
  return 0;
}
