#include <bits/stdc++.h>
using namespace std;
int a[500005];
set<pair<long long, long long> > one;
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    int zero = 0, two = -1, sign = 1;
    long long shifter = 0;
    one.clear();
    for (int i = 1; i <= n; i++) {
      int x = a[i];
      if (two != -1) {
        zero += 2;
        one.clear();
        shifter = 0, sign = 1;
        if (x - two > 0) one.insert(make_pair(x - two, x - two));
      } else if (one.size()) {
        if (sign == 1) {
          while (one.size() && shifter + one.rbegin()->first >= x)
            one.erase(*one.rbegin());
          if (one.size() && shifter + one.rbegin()->second >= x) {
            long long tmp = one.rbegin()->first;
            one.erase(*one.rbegin());
            one.insert(make_pair(tmp, x - shifter - 1));
          }
        } else {
          while (one.size() && shifter - one.begin()->second >= x)
            one.erase(*one.begin());
          if (one.size() && shifter - one.begin()->first >= x) {
            long long tmp = one.begin()->second;
            one.erase(*one.begin());
            one.insert(make_pair(shifter - x + 1, tmp));
          }
        }
        zero++, sign *= -1, shifter = x - shifter;
      } else {
        shifter = x, sign = -1;
        if (i - 1) one.insert(make_pair(1, min(a[i - 1], x) - 1));
      }
      two = -1;
      if (x & 1) continue;
      int c = (x >> 1);
      long long t = sign * (c - shifter);
      auto it = one.lower_bound(make_pair(t + 1, t + 1));
      bool flag = 0;
      if (it != one.begin()) {
        it--;
        if (it->first <= t && it->second >= t) {
          long long t1 = it->first, t2 = it->second;
          one.erase(it);
          if (t1 != t) one.insert(make_pair(t1, t - 1));
          if (t2 != t) one.insert(make_pair(t + 1, t2));
          two = c;
          flag = 1;
        }
      }
      if (!flag) one.insert(make_pair(t, t));
    }
    if (two != -1)
      printf("%d\n", 2 * n - zero - 2);
    else if (one.size())
      printf("%d\n", 2 * n - zero - 1);
    else
      printf("%d\n", 2 * n - zero);
  }
  return 0;
}
