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())
F=list(map(int,input().split()))
S=list(map(int,input().split()))


SUM=[0]*n
SUM[n-1]=F[n-1]+S[n-1]

for i in range(n-2,-1,-1):
    SUM[i]=SUM[i+1]+F[i]+S[i]


ANS1=0
for i in range(n):
    ANS1+=F[i]*i
    ANS1+=S[i]*(2*n-1-i)

#SABUN[i]=F[i+1]*2+S[i]*(2*n-1-i-i)+S[i+1]*(n-3-i-i)+SUM[2*i]*i


x=ANS1
ANS=[x]

for i in range(0,n//2,2):
    if 2*i+2>=n:
        x=x+F[i+1]*2-S[i]*(2*n-2-i-i)-S[i+1]*(2*n-4-i-i)
    else:
        x=x+F[i+1]*2-S[i]*(2*n-2-i-i)-S[i+1]*(2*n-4-i-i)+SUM[2*i+2]*2
    ANS.append(x)

print(max(ANS))




