Equilibrium Index
Find the smallest index i whose left part sum equals its right part sum (element i excluded from both). Print the 1-based index, or −1.
Input: the first line has N; the second line has N integers.
Output: the smallest equilibrium index (1-based), or −1.
Constraints:
- 1 ≤ N ≤ 105
- −104 ≤ ai ≤ 104
Sample Tests
Input 1
5 1 3 5 2 2
Output 1
3
Input 2
1 9
Output 2
1
Discussion (opens after you solve — no spoilers before)
No comments yet.