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

from itertools import accumulate
CA = [0]+A
CA = list(accumulate(CA))

CB = [0]+B
CB = list(accumulate(CB))

A1 = [0]*n
B1 = [0]*n

for j in range(n):
    A1[j] = A[j]*j
    B1[j] = B[j]*(2*n-1-j)

A2 = [0]*n
B2 = [0]*n

for j in range(n):
    A2[j] = A[j]*(2*n-1-j)
    B2[j] = B[j]*j

C1 = [0]*(n+1)
C2 = [0]*(n+1)
for j in range(1, n+1):
    C1[j] += C1[j-1]
    C1[j] += A1[j-1]+B1[j-1]
    C2[j] += C2[j-1]
    C2[j] += A2[j-1]+B2[j-1]

#print(C1)
#print(C2)

INF = 10**18
ans = -INF
t = 0
for i in range(n+1):
    if i%2 == 0:
        temp = t+C1[-1]-C1[i]+(CA[-1]-CA[i])*i+(CB[-1]-CB[i])*i
    else:
        temp = t+C2[-1]-C2[i]+(CA[-1]-CA[i])*i+(CB[-1]-CB[i])*i
    ans = max(ans, temp)
    if i != n:
        if i%2 == 0:
            t += A[i]*(2*i)+B[i]*(2*i+1)
        else:
            t += A[i]*(2*i+1)+B[i]*(2*i)
print(ans)
