human
Write me a code to sum of all Subarrays and the other steps required given the following:
Sum of all Subarrays | Set 1 | function compute sum all sub - array.
computing sum of subarray using formula.
return all subarray sum.
driver program"
Solution in Python:
assistant
#Here is code to sum of all Subarrays and the other steps required.
 def SubArraySum ( arr , n ) :
	result = 0
	for i in range ( 0 , n ) :
		result += ( arr [ i ] * ( i + 1 ) * ( n - i ) )
	return result
arr = [ 1 , 2 , 3 ]
n = len ( arr )
print ( " Sum ▁ of ▁ SubArray ▁ : ▁ " , SubArraySum ( arr , n ) )