#include <bits/stdc++.h>
using namespace std;
std::mt19937 rnd(
    (int)std::chrono::steady_clock::now().time_since_epoch().count());
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXN = 500000;
int n;
int a[MAXN];
struct OneBetter {
  int sgn;
  long long delta;
  set<pair<long long, long long>> ranges;
  void flip(int a) {
    sgn = -sgn;
    delta = a - delta;
  }
  void trim(int l, int r) {
    if (l > r) return;
    long long xl = sgn * (l - delta), xr = sgn * (r - delta);
    if (sgn == -1) swap(xl, xr);
    while (!ranges.empty()) {
      pair<long long, long long> cur = *ranges.begin();
      if (cur.first >= xl) break;
      ranges.erase(ranges.begin());
      if (cur.second < xl) continue;
      ranges.insert(make_pair(xl, cur.second));
    }
    while (!ranges.empty()) {
      pair<long long, long long> cur = *ranges.rbegin();
      if (cur.second <= xr) break;
      ranges.erase(prev(ranges.end()));
      if (cur.first > xr) continue;
      ranges.insert(make_pair(cur.first, xr));
    }
  }
  bool empty() { return ranges.empty(); }
  void add(int l, int r) {
    long long xl = sgn * (l - delta), xr = sgn * (r - delta);
    if (sgn == -1) swap(xl, xr);
    ranges.insert(make_pair(xl, xr));
  }
  void add(int y) {
    long long x = sgn * (y - delta);
    ranges.insert(make_pair(x, x));
  }
  void clear() {
    ranges.clear();
    sgn = +1;
    delta = 0;
  }
  bool contains(int y) {
    long long x = sgn * (y - delta);
    auto it = ranges.upper_bound(make_pair(x, LLONG_MAX));
    if (it == ranges.begin()) return false;
    --it;
    return x <= it->second;
  }
  void print() {
    for (auto it = ranges.begin(); it != ranges.end(); ++it)
      printf(" [%lld..%lld]", sgn * it->first + delta,
             sgn * it->second + delta);
  }
};
int low;
OneBetter better;
int twobetter;
int solve() {
  low = 0;
  better.clear();
  twobetter = -1;
  for (int i = (0); i < (n); ++i) {
    if (i - 1 >= 0) {
      if (better.empty() && twobetter == -1) {
        better.add(1, min(a[i], a[i - 1]) - 1);
      } else if (twobetter == -1) {
        ++low;
        better.trim(1, a[i] - 1);
      } else {
        low += 2;
        better.clear();
        if (twobetter < a[i]) better.add(twobetter);
        twobetter = -1;
      }
    }
    better.flip(a[i]);
    assert(twobetter == -1);
    if (a[i] % 2 == 0) {
      int half = a[i] / 2;
      if (better.contains(half)) {
        twobetter = half;
      } else {
        better.add(half);
      }
    }
  }
  int save;
  if (twobetter != -1)
    save = low + 2;
  else if (!better.empty())
    save = low + 1;
  else
    save = low;
  return 2 * n - save;
}
void run() {
  scanf("%d", &n);
  for (int i = (0); i < (n); ++i) scanf("%d", &a[i]);
  printf("%d\n", solve());
}
int main() {
  int ncase;
  scanf("%d", &ncase);
  for (int i = (1); i <= (ncase); ++i) run();
  return 0;
}
