#include <bits/stdc++.h>
using namespace std;
set<pair<long long, long long> > p;
long long a[1000010];
int main() {
  long long t, i, n;
  scanf("%lld", &t);
  while (t--) {
    scanf("%lld", &n);
    for (i = 1; i <= n; i++) scanf("%lld", &a[i]);
    long long two = 0;
    long long sign = 1, x = 0, zero = 0;
    p.clear();
    for (i = 1; i <= n; i++) {
      if (two) {
        zero += 2;
        p.clear();
        sign = 1;
        x = 0;
        if (a[i] - two > 0) p.insert(make_pair(a[i] - two, a[i] - two));
      } else {
        if (p.size()) {
          zero++;
          if (sign == 1) {
            while (p.size() && (p.rbegin()->first) + x >= a[i])
              p.erase(*p.rbegin());
            if (p.size() && (p.rbegin()->second) + x >= a[i]) {
              pair<long long, long long> h;
              h.first = p.rbegin()->first;
              h.second = a[i] - 1 - x;
              p.erase(*p.rbegin());
              p.insert(h);
            }
          } else {
            while (p.size() && x - (p.begin()->second) >= a[i])
              p.erase(*p.begin());
            if (p.size() && x - (p.begin()->first) >= a[i]) {
              pair<long long, long long> h;
              h.first = (a[i] - 1 - x) * (-1);
              h.second = p.begin()->second;
              p.erase(*p.begin());
              p.insert(h);
            }
          }
          sign *= -1;
          x = a[i] - x;
        } else {
          sign = 1;
          x = 0;
          if (i != 1)
            p.insert(make_pair(a[i] - min(a[i], a[i - 1]) + 1, a[i] - 1));
        }
      }
      if (a[i] % 2 == 0) {
        long long flag = 0;
        long long T = ((a[i] / 2) - x) * sign;
        set<pair<long long, long long> >::iterator it;
        it = p.lower_bound(make_pair(T + 1, T + 1));
        if (it != p.begin()) {
          it--;
          if ((it->first) <= T && T <= (it->second)) {
            pair<long long, long long> h1, h2;
            h1.first = it->first;
            h1.second = T - 1;
            h2.first = T + 1;
            h2.second = it->second;
            p.erase(*it);
            if (h1.first <= h1.second) p.insert(h1);
            if (h2.first <= h2.second) p.insert(h2);
            flag = 1;
          }
        }
        if (!flag) {
          p.insert(make_pair(T, T));
          two = 0;
        } else
          two = a[i] / 2;
      } else
        two = 0;
    }
    if (two)
      printf("%lld\n", n * 2 - zero - 2);
    else {
      if (p.size())
        printf("%lld\n", n * 2 - zero - 1);
      else
        printf("%lld\n", n * 2 - zero);
    }
  }
}
