The Chef is given an array of numbers and asked to find the first balance point of an array. A balance point is an index in the array N where the sum of the integers to the left of N is equal to the sum of the integers to the right of N. If there is no such balance point, print -1

-----Input-----
The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.
The first line of each test case contains a single integer N denoting the number of weights on the array. The second line contains N space-separated integers A1, A2, ..., AN denoting the weights

-----Output-----
For each test case, output a single line containing the index of the first balance point. If no such index exists, output -1

-----Constraints-----
For Subtask 1:
- 1 ≤ T ≤ 10
- 1 ≤ N ≤ 10
- -1000 ≤ A1, A2, ..., AN ≤ 1000
For Subtask 1:
- 1 ≤ T ≤ 10
- 1 ≤ N ≤ 1000
- -10000 ≤ A1, A2, ..., AN ≤ 10000

-----Example-----
Input:
2
7
7 8 9 1 9 8 7
6
1 100 50 -51 1 1

Output:
3
1

-----Explanation-----
Example case 1. In the first case, at the midpoint of the array 1, the sum of the left side {7,8,9} is equal to the sum of the right side {9,8,7}
Example case 1. In the second case, at index 1, the sum of left side =1 is equal to the sum of the right side {50,-51,1,1}

Difficulty: interview

Starter code:

Solutions:
import sys

t = eval(input())
for j in range(t):
 n = eval(input())
 a = list(map(int, input().split()))
 ch = 0
 sm = 0 ; x = sum(a)
 s1 = [0] * n ; s2 = [0] * n
 for i in range(n):
  sm += a[i]
  s1[i] = sm
  s2[i] = x
  x -= a[i]
 if(sum(a) - a[0] == 0):
  print(0)
 elif(sum(a) - a[n - 1] == 0):
  print(n - 1)
 else:
  for i in range(1, n - 1):
   if(s1[i - 1] == s2[i + 1]):
    print(i)
    ch = 1
    break
  if(ch == 0):
   if(n == 1):
    print(0)
   else:
    print(-1)


import sys

t = eval(input())
for j in range(t):
 n = eval(input())
 a = list(map(int, input().split()))
 ch = 0
 sm = 0 ; x = sum(a)
 s1 = [0] * n ; s2 = [0] * n
 for i in range(n):
  sm += a[i]
  s1[i] = sm
  s2[i] = x
  x -= a[i]
 for i in range(1, n - 1):
  if(s1[i - 1] == s2[i + 1]):
   print(i)
   ch = 1
   break
 if(ch == 0):
  if(n == 1):
   print(0)
  else:
   print(-1)


 
for i in range(eval(input())):
 n=eval(input())
 s=list(map(int,input().split()))
 f=0
 s1=0
 s2=0
 for j in range(0,n):
  s1=sum(s[0:j])
  s2=sum(s[j+1:n])
  
  if(s1 == s2):
   f=1
   print(j)
   break
 if(f==0):
  print("-1")
     


import sys

t = eval(input())
for i in range(t):
 n = eval(input())
 a = list(map(int, input().split()))
 ch = 0
 for i in range(n):
  if(sum(a[:i]) == sum(a[i + 1:])):
   print(i)
   ch = 1
   break
 if(ch == 0):
  print(-1)
    


t=eval(input())
for w in range(t):
 n=eval(input())
 lst=list(map(int,input().split()))
 total=sum(lst)
 left=0
 k=0
 for i in range(n):
  right=total-lst[i]-left
  if(right==left):
   print(i)
   k=1
   break
  left=left+lst[i]
 if(k==0):
  print('-1')


def sum_ar(arr,len):
 if (len == 0):
  return 0
 else:
  return arr[len-1] + sum_ar(arr,len-1)
t=int(input())
for i in range(t):
   n=int(input())
   li=list(map(int,input().split()))
   check=False
   for i in range(0,len(li),1):
     sli1=sum_ar(li[0:i],len(li[0:i]))
     sli2=sum_ar(li[i+1:len(li)],len(li[i+1:len(li)]))
     if(sli1==sli2):
        check=True
        break
   if(check):
     print(i)
   else:
     print(-1)


t=eval(input())

def f(arr):
 
 su = 0
 leftsum = 0
 su=sum(a)
 
 for i in range(n):
  su -= arr[i]
 
  if(leftsum == su):
   return i
 
  leftsum += arr[i]
 
 
 
 return -1

for i in range(t):
 n=eval(input())
 a=list(map(int,input().split()))
 print(f(a)) 


t=eval(input())
for i in range(t):
 n=eval(input())
 a=list(map(int,input().split()))
 f=0
 for i in range(1,n-1):
  c=0
  for j in range(0,i):
   c=c+a[j]
  if c+c==sum(a)-a[i]:
   f=i
   break
 if sum(a[1:])==0:
  print(0)
 elif sum(a[0:n-1])==0:
  print(n-1)
 elif f==0:
  print(-1)
 else:
  print(f)


t=eval(input())
for i in range(t):
 n=eval(input())
 a=list(map(int,input().split()))
 f=0
 for i in range(1,n-1):
  if sum(a[0:i])==sum(a[i+1:]):
   
   f=i
   break
 if sum(a[1:])==0:
  print(0)
 elif sum(a[0:n-1])==0:
  print(n-1)
 elif f==0:
  print(-1)
 else:
  print(f)



l=[]
n=int(input())
for i in range(0,n):
 s=int(input())
 l=[]
 l=list(map(int,input().split()))
 beg=0
 suml=0
 sumr=0
 for j in range(0,len(l)):
  sumr=sumr+l[j]
 for j in range(0,len(l)):
  sumr=sumr-l[j]
  if(sumr==suml):
   print(j)
   beg=1
   break
  suml=suml+l[j]
 if(beg==0):
  print(-1)

for i in range(eval(input())):
 lsum,rsum,n,bp=0,0,eval(input()),0
 weights=input().split()
 weights=[int(x) for x in weights]
 for i in range(n):
  if sum(weights[0:i])==sum(weights[i+1::]):
   bp=1
   break
 if bp==1: print(i)
 else: print("-1")