6
12 8 12 17 20 5
17 4 8 8 8 4
 6
4 1 12 9 3 11
12 20 19 12 19 11
 1
1
1
 2
1 2
1 1
 1
7
5
 6
16 20 18 7 14 2
17 12 4 10 7 4

705
 917
 1
 9
 5
 741

# from math import ceil
#from sys import stdout

t = 1#int(input())
for test in range(1,t+1):
    n = int(input())
    a = [list(map(int, input().split()))]
    a.append(list(map(int, input().split())))
    pre = [0]
    index = 0
    tmp = 0
    pre2 = [0]
    pre3 = [0]
    pre4 = [0]
    for i in range(2*n):
        pre.append(pre[-1]+i*a[tmp][index])
        if i%2==0:
            tmp = (tmp+1)%2
        else:
            index+=1
    for i in range(n):
        pre2.append(pre2[-1]+a[0][i]+a[1][i])
    ans = 0
    for i in range(n):
        pre3.append(pre3[-1]+i*a[0][i])
    index = n-1
    for i in range(n,2*n):
        pre3.append(pre3[-1]+i*a[1][index])
        index-=1

    for i in range(n):
        ans = max(pre[(i)*2]+(pre2[-1]-pre2[i])*i+pre3[2*n-i]-pre3[i], ans)
    print(ans)








    
