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())

t = 0
v1 = 0
v2 = 0
ans = 0
arr = []
s1 = [0]*n
s2 = [0]*n

t1 = list(map(int, input().split()))
arr.append(t1)
t2 = list(map(int, input().split()))
arr.append(t2)

for i in range(n):
    v1 += t*arr[0][i]
    v2 += (t+1)*arr[1][i]
    t += 1

for i in range(n-1, -1, -1):
    v1 += t*arr[1][i]
    v2 += (t+1)*arr[0][i]
    t += 1


ans = max(v1, v2)

s1[n-1] = arr[0][n-1]
s2[n-1] = arr[1][n-1]

for i in range(n-2, -1, -1):

    s1[i] += s1[i+1] + arr[0][i];
    s2[i] += s2[i+1] + arr[1][i];


base = 1*arr[1][0] + 2*arr[1][1] + 3*arr[0][1];
v1 = 0;
t = 4;

for i in range(2, n):
    v1 += t*arr[0][i];
    t += 1

for i in range(n-1, 1, -1):
    v1 += t*arr[1][i]
    t += 1


v2 = 0
t = 6
for i in range(3, n):
    v2 += t*arr[1][i]
    t += 1

for i in range(n-1, 2, -1):
    v2 += t*arr[0][i]
    t += 1

ans = max(ans, max(base+v1, base + 4*arr[0][2] + 5*arr[1][2] + v2))

base = base + 4*arr[0][2] + 5*arr[1][2]

t = 6;
k = 2

for i in range(3, n-1):

    if i%2 == 1:
        v1 += k*(s1[i+1] + s2[i+1])
        v1 -= (t-1)*arr[0][i] + (t-2)*arr[0][i-1] + (2*n-1)*arr[1][i-1] + (2*n-2)*arr[1][i]
        base += t*arr[1][i] + (t+1)*arr[0][i]
        ans = max(ans, base + v1)
    
    else:
        v2 += k*(s1[i+1] + s2[i+1])
        v2 -= (t-1)*arr[1][i] + (t-2)*arr[1][i-1] + (2*n-1)*arr[0][i-1] + (2*n-2)*arr[0][i]
        base += t*arr[0][i] + (t+1)*arr[1][i]
        ans = max(ans, base + v2)
    
    t += 2

print(ans)