#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long te;
  cin >> te;
  while (te--) {
    long long a;
    cin >> a;
    long long b[a], c[a];
    long long g1 = 0, g2 = 0, m = 2;
    long long ans = 2 * a;
    for (int i = 0; i < a; i++) {
      cin >> b[i];
      if (b[i] == 1) {
        g1++;
      } else {
        g2++;
      }
    }
    for (int i = 0; i < a; i++) {
      cin >> c[i];
      if (c[i] == 1) {
        g1++;
      } else {
        g2++;
      }
    }
    long long k = abs(g1 - g2);
    if (g1 == g2) {
      ans = 0;
    }
    reverse(b, b + a);
    if (g1 > g2) {
      m = 1;
    }
    map<long long, long long> d, e;
    long long m1 = 0, m2 = 0;
    for (int i = 0; i < a; i++) {
      if (b[i] == m) {
        m1++;
      }
      if (b[i] != m) {
        m1--;
      }
      if (c[i] == m) {
        m2++;
      }
      if (c[i] != m) {
        m2--;
      }
      d[m1]++;
      d[m1]--;
      e[m2]++;
      e[m2]--;
      if (d[m1] == 0) {
        d[m1] = i + 1;
      }
      if (e[m2] == 0) {
        e[m2] = i + 1;
      }
    }
    for (auto j : d) {
      long long x = j.first, y = j.second;
      long long u = k - x;
      long long ans1;
      e[u]++;
      e[u]--;
      if (e[u] == 0) {
        ans1 = 10e9;
      } else {
        ans1 = y + e[u];
      }
      ans = min(ans, ans1);
    }
    e[k]++;
    e[k]--;
    d[k]++;
    d[k]--;
    if (e[k] != 0) {
      ans = min(ans, e[k]);
    }
    if (d[k] != 0) {
      ans = min(ans, d[k]);
    }
    cout << ans << endl;
  }
  return 0;
}
