':type A: List[int]
:rtype: int'

def maxRotateFunction(self, A):

    s = sum(A)
    fi = 0
    for i in xrange(len(A)):
        fi += (i * A[i])
    result = fi
    for i in xrange(1, (len(A) + 1)):
        fi += (s - (len(A) * A[(- i)]))
        result = max(result, fi)
    return result
