Codeforces Round 851 (Div. 2)
A
One and Two
Codeforces
800
原题
←B →
翻译中…

You are given a sequence $a_1, a_2, \ldots, a_n$. Each element of $a$ is $1$ or $2$.

翻译中…

Find out if an integer $k$ exists so that the following conditions are met.

翻译中…
  • $1 \leq k \leq n-1$, and
  • $a_1 \cdot a_2 \cdot \ldots \cdot a_k = a_{k+1} \cdot a_{k+2} \cdot \ldots \cdot a_n$.
翻译中…

If there exist multiple $k$ that satisfy the given condition, print the smallest.

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 100$). Description of the test cases follows.

翻译中…

The first line of each test case contains one integer $n$ ($2 \leq n \leq 1000$).

翻译中…

The second line of each test case contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \leq a_i \leq 2$).

翻译中…

Output

翻译中…

For each test case, if there is no such $k$, print $-1$.

翻译中…

Otherwise, print the smallest possible $k$.

翻译中…

Note

翻译中…

For the first test case, $k=2$ satisfies the condition since $a_1 \cdot a_2 = a_3 \cdot a_4 \cdot a_5 \cdot a_6 = 4$. $k=3$ also satisfies the given condition, but the smallest should be printed.

翻译中…

For the second test case, there is no $k$ that satisfies $a_1 \cdot a_2 \cdot \ldots \cdot a_k = a_{k+1} \cdot a_{k+2} \cdot \ldots \cdot a_n$

翻译中…

For the third test case, $k=1$, $2$, and $3$ satisfy the given condition, so the answer is $1$.

翻译中…

样例

Input #1
3
6
2 2 1 2 1 2
3
1 2 1
4
1 1 1 1
Output #1
2
-1
1
InputCopy OutputCopy
题目信息
题号
1788A
时间限制
1 s
内存限制
256 MB
标签
暴力
模拟
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。