#include <bits/stdc++.h>
using namespace std;
struct Data {
  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({x, x});
  }
  void clear() {
    ranges.clear();
    sgn = 1;
    delta = 0;
  }
  bool contain(int y) {
    long long x = sgn * (y - delta);
    auto it = ranges.upper_bound({x, LLONG_MAX});
    if (it == ranges.begin()) return 0;
    return (prev(it)->second) >= x && (prev(it)->first) <= x;
  }
};
int n, a[500005];
int solve() {
  int cnt = 0;
  Data Seg;
  Seg.clear();
  for (int i = 0; i < n; i++) {
    Seg.trim(1, a[i] - 1);
    if (Seg.empty())
      Seg.add(1, a[i] - 1);
    else
      cnt++;
    Seg.flip(a[i]);
    if (a[i] % 2 == 0) {
      int b = a[i] / 2;
      if (Seg.contain(b)) {
        cnt++;
        Seg.clear();
      }
      Seg.add(b);
    }
  }
  return 2 * n - cnt;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int T;
  for (cin >> T; T--;) {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    cout << solve() << endl;
  }
  return 0;
}
