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()))
s = 0
sumTop = [0]*n
s = 0
for i in range (n-1,-1,-1):
    s+=a[i]
    sumTop[i] = s
s = 0
sumBottom = [0]*n
for i in range (n-1,-1,-1):
    s+=b[i]
    sumBottom[i] = s
dpTop = [0]*n
s = 0
for i in range(n):
    s+=a[i]*i
    s+=b[i]*(2*n-i-1)
dpTop[0] = s

dpBottom = [0]*n
s = 0

for i in range(n):
    s+=b[i]*i
    s+=a[i]*(2*n-i-1)
dpBottom[0] = s
for i in range(1,n):
    dpTop[i] = dpTop[i-1] - sumTop[i] - sumBottom[i] - b[i-1]*(2*n - (i-1)*2 - 1)
for i in range(1,n):
    dpBottom[i] = dpBottom[i-1] - sumTop[i] - sumBottom[i] - a[i-1]*(2*n - (i-1)*2 - 1)
ans = dpTop[0]
dpTop.append(0)
dpBottom.append(0)
s = 0
for i in range(n):


    if (i%2):
        s += a[i] * (2*i+1)
        s += b[i] * (2*i)
        ans = max(ans,s+dpTop[i+1])
    else:
        s += a[i] * (2*i)
        s += b[i] * (2*i+1)
        ans = max(ans,s+dpBottom[i+1])
print(ans)