```
class Solution(object):
def maxRotateFunction(self, nums):
now, sums, res, n = sum(i * nums[i] for i in range(len(nums))), sum(nums), float('-inf'), len(nums)
for i in range(n):
res, now = max(now, res), now + sums - n * nums[n - i - 1]
return res if res != float('-inf') else 0
```