#include <bits/stdc++.h>
using namespace std;
int mc, T, n;
long long a[500005], A, B, x, y;
set<pair<long long, long long> > js;
void clear() {
  js.clear();
  A = 0;
  B = 1;
}
int main() {
  scanf("%d", &T);
  for (; T--;) {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    clear();
    if (a[1] % 2 == 0) {
      mc = 1;
      js.insert(pair<long long, long long>{a[1] / 2, a[1] / 2});
    } else {
      mc = 0;
      js.insert(pair<long long, long long>{1, a[1] - 1});
    }
    for (int i = 2; i <= n; i++) {
      x = a[i];
      if (B > 0) {
        while (!js.empty() && js.rbegin()->first >= x - A) js.erase(--js.end());
        if (!js.empty() && js.rbegin()->second >= x - A) {
          long long fi = js.rbegin()->first;
          js.erase(--js.end());
          if (fi < x - A) js.insert(pair<long long, long long>{fi, x - A - 1});
        }
      } else {
        while (!js.empty() && js.begin()->second <= A - x) js.erase(js.begin());
        if (!js.empty() && js.begin()->first <= A - x) {
          long long se = js.begin()->second;
          js.erase(js.begin());
          if (se > A - x) js.insert(pair<long long, long long>{A - x + 1, se});
        }
      }
      A = x - A;
      B = -B;
      if (js.empty()) {
        js.insert(pair<long long, long long>{1, x - 1});
        A = 0;
        B = 1;
      } else
        mc++;
      if (x % 2 == 0) {
        y = x / 2;
        long long j = (y - A) / B;
        int flag = 0;
        set<pair<long long, long long> >::iterator it =
            js.lower_bound(pair<long long, long long>{j + 1, (long long)-1e18});
        if (it != js.begin()) {
          --it;
          if (it->first <= j && it->second >= j) flag = 1;
        }
        if (flag) {
          js.clear();
          js.insert(pair<long long, long long>{y, y});
          A = 0;
          B = 1;
          mc++;
        } else
          js.insert(pair<long long, long long>{j, j});
      }
    }
    printf("%d\n", 2 * n - mc);
  }
  return 0;
}
