• + 0 comments

    Python

    n = int(input())
    
    arr = list(map(int, input().split()))
    
    og_sum = sum(arr)
    
    total_sum = sum([(i+1) * arr[i] for i in range(n)])
    max_sum = total_sum
    
    
    for i in range(1, n):
        total_sum += (n * arr[i-1]) - og_sum
        max_sum = max(max_sum, total_sum)
        
        
    print(max_sum)