```
class Solution(object):
def maxRotateFunction(self, A):
"""
:type A: List[int]
:rtype: int
"""
total = sum(A)
best_so_far = candidate = sum([i*A[i] for i in range(len(A))])
for i in range(len(A)-1, -1, -1):
candidate += total - A[i]*len(A)
best_so_far = max(best_so_far, candidate)
return best_so_far
```