#C11495. Equilibrium Index in an Array
Equilibrium Index in an Array
Equilibrium Index in an Array
Given an array (A) of integers, find an index (i) such that the sum of the elements on the left of (i) is equal to the sum of the elements on the right of (i). Formally, find the smallest index (i) that satisfies [ \sum_{j=0}^{i-1} A[j] = \sum_{j=i+1}^{n-1} A[j] ] If no such index exists, output (-1). The input is provided as the number of elements followed by the list of integers.
inputFormat
The first line contains an integer (n) ((1 \leq n \leq 10^5)), representing the number of elements in the array. The second line contains (n) space-separated integers that constitute the array.
outputFormat
Output a single integer representing the equilibrium index. If the equilibrium index does not exist, output (-1).## sample
7
-7 1 5 2 -4 3 0
3
</p>