human
Count array elements that can be represented as sum of at least two consecutive array elements | Function to find the number of array elements that can be represented as the sum of two or more consecutive array elements.
Stores the frequencies of array elements.
Stores required count.
Update frequency of each array element.
Find sum of all subarrays.
Increment ans by cnt [ sum ].
Reset cnt [ sum ] by 0.
Return ans.
Driver Code.
Given array.
Function call"
Solution in Python:
assistant
#Here is code to count array elements that can be represented as sum of at least two consecutive array elements and the other steps required.
 def countElements ( a , n ) :
	cnt = [ 0 ] * ( n + 1 )
	ans = 0
	for k in a :
		cnt [ k ] += 1
	for l in range ( n ) :
		sum = 0
		for r in range ( l , n ) :
			sum += a [ r ]
			if ( l == r ) :
				continue
			if ( sum <= n ) :
				ans += cnt [ sum ]
				cnt [ sum ] = 0
	return ans
if __name__ == ' _ _ main _ _ ' :
	a = [ 1 , 1 , 1 , 1 , 1 ]
	print ( countElements ( a , len ( a ) ) )