#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
const long double pi = acos(-1.0);
const long double eps = 1e-5;
const int INF = 0x3f3f3f3f;
const long long INFLL = 0x3f3f3f3f3f3f3f3f;
const long long mod = 998244353;
int f[200010];
int a[200010];
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int T;
  cin >> T;
  while (T--) {
    int n;
    cin >> n;
    memset(f, (-0x3f), sizeof(f));
    f[100010] = 0;
    int sum = 0;
    int ans = 0;
    for (int i = (1); i <= (n); i++) {
      int t;
      cin >> t;
      sum += t == 1 ? 1 : -1;
      f[sum + 100010] = max(f[sum + 100010], i);
      if (!sum) ans = max(ans, f[sum + 100010]);
    }
    for (int i = (1); i <= (n); i++) cin >> a[i];
    sum = 0;
    for (int i = (n); i >= (1); i--) {
      sum += a[i] == 1 ? 1 : -1;
      ans = max(n - i + 1 + f[-sum + 100010], ans);
    }
    cout << 2 * n - ans << '\n';
  }
  return 0;
}
