#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (int i = n - 1; i >= 0; i--) {
      cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
      cin >> b[i];
    }
    vector<pair<int, int>> a1(n + 1), b1(n + 1);
    a1[n - 1] = {a[n - 1] == 1, a[n - 1] == 2};
    for (int i = n - 2; i >= 0; i--) {
      pair<int, int> ant = a1[i + 1];
      a1[i] = {ant.first + (a[i] == 1), ant.second + (a[i] == 2)};
    }
    b1[n - 1] = {b[n - 1] == 1, b[n - 1] == 2};
    for (int i = n - 2; i >= 0; i--) {
      pair<int, int> ant = b1[i + 1];
      b1[i] = {ant.first + (b[i] == 1), ant.second + (b[i] == 2)};
    }
    vector<int> arr1(n + 1, -1);
    vector<int> arr2(n + 1, -1);
    a1[n].first = 0;
    a1[n].second = 0;
    for (int i = 0; i <= n; i++) {
      int d = a1[i].first - a1[i].second;
      if (d > 0) {
        if (arr1[d] == -1) arr1[d] = i;
      } else if (d < 0) {
        d *= -1;
        if (arr2[d] == -1) arr2[d] = i;
      } else {
        if (arr1[0] == -1) arr1[0] = i;
        if (arr2[0] == -1) arr2[0] = i;
      }
    }
    int res = 0x3f3f3f3f;
    b1[n].first = 0;
    b1[n].second = 0;
    for (int i = 0; i <= n; i++) {
      int f = b1[i].first - b1[i].second;
      if (f < 0) {
        f *= -1;
        if (arr1[f] != -1) {
          res = min(res, arr1[f] + i);
        }
      } else if (f > 0) {
        if (arr2[f] != -1) {
          res = min(res, arr2[f] + i);
        }
      } else {
        if (arr1[0] != -1) res = min(res, arr1[0] + i);
        if (arr2[0] != -1) res = min(res, arr2[0] + i);
      }
    }
    if (b1[0].first == b1[0].second) res = min(res, n);
    if (a1[0].first == a1[0].second) res = min(res, n);
    cout << ((res == 0x3f3f3f3f) ? 2 * n : res) << "\n";
  }
  return 0;
}
