#include <bits/stdc++.h>
#pragma GCC optimize "-O3"
using namespace std;
int n;
void fill_diff(int x[], int diff_x[], int prefx[]) {
  int cnt = 0;
  for (int i = 0; i < (int)n; i++) {
    if (x[i] == 1)
      cnt++;
    else
      cnt--;
    prefx[i] = cnt;
    if (diff_x[cnt + 2 * n] == -1) diff_x[cnt + 2 * n] = i + 1;
  }
  diff_x[0 + 2 * n] = 0;
}
int min_diff(int prefx[], int diff_y[], int goal) {
  if (goal == 0) return 0;
  int ans = INT_MAX;
  if (diff_y[goal + 2 * n] != -1) ans = diff_y[goal + 2 * n];
  for (int i = 0; i < (int)n; i++) {
    if (diff_y[goal - prefx[i] + 2 * n] != -1) {
      ans = min(ans, i + 1 + diff_y[goal - prefx[i] + 2 * n]);
    }
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    cin >> n;
    int a[n], b[n];
    int ones = 0, twos = 0;
    for (int i = 0; i < (int)n; i++) {
      cin >> a[i];
      if (a[i] == 1)
        ones++;
      else
        twos++;
    }
    for (int i = 0; i < (int)n; i++) {
      cin >> b[i];
      if (b[i] == 1)
        ones++;
      else
        twos++;
    }
    int goal = ones - twos;
    int diff_a[400005], diff_b[400005];
    fill(diff_a, diff_a + 400005, -1);
    fill(diff_b, diff_b + 400005, -1);
    int prefa[n], prefb[n];
    reverse(a, a + n);
    fill_diff(a, diff_a, prefa);
    fill_diff(b, diff_b, prefb);
    int ans = min_diff(prefa, diff_b, goal);
    cout << ans << "\n";
  }
  return 0;
}
