------
## 最终结论
```python
def min_jars_to_empty(t, test_cases):
    results = []
    
    for n, jars in test_cases:
        left_strawberry = [0] * (n + 1)
        left_blueberry = [0] * (n + 1)
        right_strawberry = [0] * (n + 1)
        right_blueberry = [0] * (n + 1)

        for i in range(1, n + 1):
            left_strawberry[i] = left_strawberry[i - 1]
            left_blueberry[i] = left_blueberry[i - 1]
            if jars[i - 1] == 1:
                left_strawberry[i] += 1
            else:
                left_blueberry[i] += 1

        for i in range(n, 2 * n):
            right_strawberry[2 * n - i] = right_strawberry[2 * n - i - 1]
            right_blueberry[2 * n - i] = right_blueberry[2 * n - i - 1]
            if jars[i] == 1:
                right_strawberry[2 * n - i] += 1
            else:
                right_blueberry[2 * n - i] += 1

        total_strawberries = left_strawberry[n] + right_strawberry[n]
        total_blueberries = left_blueberry[n] + right_blueberry[n]

        min_moves = float('inf')

        for k in range(n + 1):
            strawberries_left = left_strawberry[k]
            blueberries_left = left_blueberry[k]

            strawberries_right_needed = total_strawberries // 2 - strawberries_left
            blueberries_right_needed = total_blueberries // 2 - blueberries_left

            if strawberries_right_needed >= 0 and blueberries_right_needed >= 0:
                moves_needed = max(strawberries_right_needed, blueberries_right_needed) + k
                min_moves = min(min_moves, moves_needed)

        results.append(min_moves)

    return results

# Read input and output the result for each test case
import sys
input = sys.stdin.read
data = input().split()

t = int(data[0])
index = 1
test_cases = []

for _ in range(t):
    n = int(data[index])
    jars = list(map(int, data[index+1:index+2*n+1]))
    test_cases.append((n, jars))
    index += 2*n + 1

results = min_jars_to_empty(t, test_cases)
for result in results:
    print(result)
```