```
class Solution(object):
def maxRotateFunction(self, A):
"""
:type A: List[int]
:rtype: int
"""
len_a = len(A)
sum_a = sum(A)
if len_a == 0:
return 0
s = [0] * len_a
for i in xrange(len_a):
s[0] += i * A[i]
for i in xrange(1, len_a):
# calculate next by prev
s[i] = s[i-1] + sum_a - A[len_a - i] * len_a
return max(s)
```