• + 0 comments

    Python. Small Code.....

    n=int(input())
    x=[int(i) for i in input().split()]
    s=sum(x)
    p=0
    for i in range(n):p+= (i+1)*x[i]
    ma=p
    for i in range(n-1,-1,-1):
        p+=s-n*x[i]
        ma=max(p,ma)
    print(ma)