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 = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

sm = [0]*(n+1)

for i in range(n):
    j = n-i-1
    sm[j] = sm[j+1] + a[j] + b[j]

fval = [0]
bval = [0]

for i in range(1,n):
    fval.append(i*a[i] + fval[i-1])
    bval.append(i*b[i] + bval[i-1])

for i in range(n,2*n):
    fval.append(i*b[2*n - i - 1] + fval[i-1])
    bval.append(i*a[2*n - i - 1] + bval[i-1])

curr = 0
best = fval[-1]
j = 0
for i in range(1,n+1):
    if(i%2 == 0):
        curr += b[i-1]*j + a[i-1]*(j+1)
        delta = fval[2*n - i - 1] - fval[i-1] + (j-i)*sm[i]
        best = max(best,curr + delta)
    else:
        curr += a[i-1]*j + b[i-1]*(j+1)
        delta = bval[2*n - i - 1] - bval[i-1] + (j-i)*sm[i]
        best = max(best,curr +  delta)
    j += 2

print(best)