~/algor $ cat problems/massiv-teng-yigindili-bolinish
Split into equal sums
Easy
1000 ms
64 MB
33%
An array of $n$ integers is given. Find the smallest $k$ ($1 \le k \lt n$) such that the sum of the first $k$ elements is equal to the sum of the remaining elements. If there is no such $k$, print $-1$.
Input
The first line contains a positive integer $n$.
The second line contains $n$ integers — the elements of the array.
Output
One integer — $k$ or $-1$.
Note
$1 \le n \le 1001$
the elements are from $-10^{6}$ to $10^{6}$
Examples
Input #1
6 4 1 5 3 2 5
Output #1
3
Input #2
3 1 2 4
Output #2
-1