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

n = int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
v1,v2,v3=0,0,0
for i in range(n):
    v1+=i*a[i]
    if i!=0:
        v2+=(2*n-i)*a[i]
for i in range(n):
    v1+=(n-i+n-1)*b[i]
    v2+=(i+1)*b[i]
t=1
i=1
k=0
z=0
j=0
while i<2*n:
    z+=1
    if t==0:
        v3+=i*a[j]
    elif t==1:
        v3+=i*b[j]
    if z==2:
        z=0
        t=1-t
    elif z==1:
        j+=1
    i+=1
print(max(v1,v2,v3))
        
    
    
    