#include <bits/stdc++.h>
using namespace std;
struct node {
  long long l, r;
  friend bool operator<(node a, node b) {
    return a.l != b.l ? a.l < b.l : a.r < b.r;
  }
};
set<node> s;
set<node>::iterator it;
int T, n, a[500005], dp[500005];
long long rv, dt;
int main() {
  scanf("%d", &T);
  while (T--) {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for (int i = 1; i <= n; i++) dp[i] = 0;
    s.clear();
    rv = dt = 0;
    if (a[1] & 1) {
      s.insert((node){1, a[1] - 1});
    } else {
      s.insert((node){a[1] / 2, a[1] / 2});
      dp[1] = 1;
    }
    for (int i = 2; i <= n; i++) {
      if (a[i] & 1) {
        if (rv) {
          while (!s.empty() && s.begin()->r <= dt - a[i]) s.erase(s.begin());
          if (!s.empty()) {
            node nd = *s.begin();
            s.erase(nd);
            nd.l = -nd.l + dt, nd.r = -nd.r + dt;
            nd.l = min(nd.l, 1ll * a[i] - 1);
            nd.l = dt - nd.l, nd.r = dt - nd.r;
            s.insert(nd);
            dp[i] = dp[i - 1] + 1;
            rv = 0;
            dt = a[i] - dt;
          } else {
            dp[i] = dp[i - 1];
            dt = rv = 0;
            s.clear();
            s.insert((node){1, a[i] - 1});
          }
        } else {
          while (!s.empty() && (--s.end())->l >= a[i] - dt) s.erase(--s.end());
          if (!s.empty()) {
            node nd = *(--s.end());
            s.erase(nd);
            nd.l += dt, nd.r += dt;
            nd.r = min(nd.r, 1ll * a[i] - 1);
            nd.l -= dt, nd.r -= dt;
            s.insert(nd);
            dp[i] = dp[i - 1] + 1;
            rv = 1;
            dt = a[i] - dt;
          } else {
            dp[i] = dp[i - 1];
            dt = rv = 0;
            s.clear();
            s.insert((node){1, a[i] - 1});
          }
        }
      } else {
        if (rv) {
          long long x = dt - a[i] / 2;
          node nd = (node){x + 1, -2000000000000000000};
          it = s.lower_bound(nd);
          if (it != s.begin() && (--it)->r >= x) {
            dp[i] = dp[i - 1] + 2;
            s.clear();
            s.insert((node){a[i] / 2, a[i] / 2});
            dt = rv = 0;
          } else {
            dp[i] = dp[i - 1] + 1;
            while (!s.empty() && s.begin()->r <= dt - a[i]) s.erase(s.begin());
            if (!s.empty()) {
              node nd = *s.begin();
              s.erase(nd);
              nd.l = -nd.l + dt, nd.r = -nd.r + dt;
              nd.l = min(nd.l, 1ll * a[i] - 1);
              nd.l = dt - nd.l, nd.r = dt - nd.r;
              s.insert(nd);
              dp[i] = dp[i - 1] + 1;
              rv = 0;
              dt = a[i] - dt;
            } else {
              s.clear();
              dt = rv = 0;
            }
            s.insert((node){a[i] / 2 - dt, a[i] / 2 - dt});
          }
        } else {
          long long x = a[i] / 2 - dt;
          node nd = (node){x + 1, -2000000000000000000};
          it = s.lower_bound(nd);
          if (it != s.begin() && (--it)->r >= x) {
            dp[i] = dp[i - 1] + 2;
            s.clear();
            s.insert((node){a[i] / 2, a[i] / 2});
            dt = rv = 0;
          } else {
            dp[i] = dp[i - 1] + 1;
            while (!s.empty() && (--s.end())->l >= a[i] - dt)
              s.erase(--s.end());
            if (!s.empty()) {
              node nd = *(--s.end());
              s.erase(nd);
              nd.l += dt, nd.r += dt;
              nd.r = min(nd.r, 1ll * a[i] - 1);
              nd.l -= dt, nd.r -= dt;
              s.insert(nd);
              dp[i] = dp[i - 1] + 1;
              rv = 1;
              dt = a[i] - dt;
              s.insert((node){dt - a[i] / 2, dt - a[i] / 2});
            } else {
              s.clear();
              dt = rv = 0;
              s.insert((node){a[i] / 2, a[i] / 2});
            }
          }
        }
      }
    }
    printf("%d\n", 2 * n - dp[n]);
  }
}
