human
What is a code to rearrange an array to maximize i * arr [ i ] and the other steps required given the following:
Rearrange an array to maximize i * arr [ i ] | Function to calculate the maximum points earned by making an optimal selection on the given array.
Sorting the array.
Variable to store the total points earned.
Driver Code"
How can the above be solved in Python?
assistant
#Here is code to rearrange an array to maximize i * arr [ i ] and the other steps required.
 def findOptimalSolution ( a , N ) :
	a . sort ( )
	points = 0
	for i in range ( 0 , N ) :
		points += a [ i ] * i
	return points
if __name__ == " _ _ main _ _ " :
	a = [ 1 , 4 , 2 , 3 , 9 ]
	N = len ( a )
	print ( findOptimalSolution ( a , N ) )