```
class Solution(object):
def maxRotateFunction(self, A):
"""
:type A: List[int]
:rtype: int
"""
s = sum(A)
res_list = [0]
n = len(A)
res = 0
for i in A:
tmp = i*(n-1)-(s-i)+res_list[-1] #tmp is the profit of one movement
res_list.append(tmp)
for i,j in enumerate(A):
res+=i*j
return res+max(res_list)
```