#K71127. Find the Balance Index

    ID: 33463 Type: Default 1000ms 256MiB

Find the Balance Index

Find the Balance Index

You are given several test cases. In each test case, you are given a sequence of n positive integers. Your task is to find the smallest index \(k\) (with \(1 \leq k \leq n-1\)) such that:

\(\sum_{i=1}^{k} a_i = \sum_{i=k+1}^{n} a_i\)

If no such index exists, output \(-1\) for that test case.

Note: The index is 1-indexed and the split must occur within the sequence (i.e. you cannot take \(k = n\)).

inputFormat

The input is read from standard input (stdin) and has the following format:

T
n a1 a2 ... an
n a1 a2 ... an
... (T test cases in total)

Here, \(T\) is the number of test cases. For each test case, the first integer \(n\) indicates the number of elements in the sequence followed by \(n\) positive integers.

outputFormat

For each test case, output one integer on a new line: the smallest index \(k\) that satisfies the balance condition, or \(-1\) if no valid index exists.

## sample
2
5 1 2 3 0 6
4 1 1 1 1
3

2

</p>