help in binary search problem.

binary-search
codeforces

#1

Can someone explain me what am i doing wrong in applying binary search in this
problem.
My solution:

def binary(aa,val):
	lo=0
	hi=len(aa)-1
	
	
	while(lo<=hi):
		mid=(hi+lo)//2
		
		if(val<=aa[mid] and mid==0):
			
			return mid+1
		if(val<=aa[mid] and val>=aa[mid-1] and mid!=0):
			
			return mid+1
		elif(val>a[mid]):
			lo=mid+1
			
		else:
			hi=mid-1
			
	return 0

n=int(input())
a=list(map(int,input().split()))
m=int(input())
q=list(map(int,input().split()))
aa=[]
sa=0

for i in a:
	sa+=i
	aa.append(sa)


for i in range(m):
	
	print(binary(aa,q*))