human
Count of subarrays which start and end with the same element | Function to find total sub - array which start and end with same element.
Initialize result with 0.
Array to count frequency of 1 to N.
Update frequency of A [ i ].
Update result with sub - array contributed by number i.
Print the result.
Driver code"
How can the above be solved in Python?

=====
Can you provide a code to count of subarrays which start and end with the same element and the other steps required?
assistant
#Here is code to count of subarrays which start and end with the same element and the other steps required.
 def cntArray ( A , N ) :
	result = 0
	frequency = [ 0 ] * ( N + 1 )
	for i in range ( 0 , N ) :
		frequency [ A [ i ] ] = frequency [ A [ i ] ] + 1
	for i in range ( 1 , N + 1 ) :
		frequency_of_i = frequency [ i ]
		result = result + ( ( frequency_of_i ) * ( frequency_of_i + 1 ) ) / 2
	print ( int ( result ) )
	print ( " " )
A = [ 1 , 5 , 6 , 1 , 9 , 5 , 8 , 10 , 8 , 9 ]
N = len ( A )
cntArray ( A , N )