#include <bits/stdc++.h>
using namespace std;
template <class T>
bool umin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool umax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
int pre[200009], suf[200009], dp[200009], arr[200009];
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
      int x;
      scanf("%d", &x);
      pre[i] = pre[i - 1];
      if (x == 1)
        pre[i]++;
      else
        pre[i]--;
    }
    for (int i = 1; i <= n; i++) {
      scanf("%d", &arr[i]);
      if (arr[i] == 2) arr[i] = -1;
    }
    dp[n] = n + 1;
    suf[n + 1] = 0;
    for (int i = n; i >= 1; i--) {
      suf[i] = suf[i + 1] + arr[i];
      dp[suf[i] + n] = i;
    }
    int ans = 0;
    for (int i = 0; i <= n; i++)
      if (dp[-pre[i] + n]) umax(ans, i + (n - dp[-pre[i] + n] + 1));
    printf("%d\n", 2 * n - ans);
    for (int i = 0; i <= 2 * n; i++) dp[i] = 0;
  }
  return 0;
}
