human
Count of elements which is the sum of a subarray of the given Array | Function to count element such that their exist a subarray whose sum is equal to this element.
Loop to compute frequency of the given elements.
Loop to iterate over every possible subarray of array.
Driver Code"
Solution in Python:
assistant
#Here is code to count of elements which is the sum of a subarray of the given Array and the other steps required.
 def countElement ( arr , n ) :
	freq = { }
	ans = 0
	for i in range ( n ) :
		freq [ arr [ i ] ] = freq . get ( arr [ i ] , 0 ) + 1
	for i in range ( n - 1 ) :
		tmpsum = arr [ i ]
		for j in range ( i + 1 , n ) :
			tmpsum += arr [ j ]
			if tmpsum in freq :
				ans += freq [ tmpsum ]
	return ans
if __name__ == " _ _ main _ _ " :
	arr = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 ]
	n = len ( arr )
	print ( countElement ( arr , n ) )