```
class Solution(object):
def maxRotateFunction(self, A):
n= len(A)
total, sum, max= 0, 0 , -100000000000000
if(n==0): return 0
for i in range(n):
total+= i*A[i]
sum+= A[i]
for i in range(n):
prev= total
total+= (n*A[i] - sum)
if(max < total):
max= total
return max
```