Shuvo also wants to find a day in the sales record where everything sold BEFORE that day exactly balances everything sold AFTER it — a natural "equilibrium point" for the fiscal report. Find any index i (0-indexed) such that the sum of elements before i equals the sum of elements after i. Print -1 if none exists.
Input
Line1: N. Line2: N integers.
Output
An equilibrium index, or -1.
Constraints
1 ≤ N ≤ 10^5
Sample Input
5 -7 1 5 2 -4
Sample Output
3
main.c
Loading editor…
Write C, then Run (custom I/O) or Submit (sample tests). ⌘/Ctrl+Enter submits.