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

from __future__ import print_function,division
import sys
if sys.version_info < (3, 0):
    range = xrange
input = sys.stdin.readline

n = int(input())

A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

DP = [0]*2*(n+1)

roundwina = 0
t = 1
sa = 0
for a in A[1:]:
    roundwina += t*a
    sa += a
    t += 1
for b in reversed(B[1:]):
    roundwina += t*b
    sa += b
    t += 1

roundwinb = 0
sb = 0
t = 2
for b in B[1:]:
    roundwinb += t*b
    sb += b
    t += 1
for a in reversed(A[1:]):
    roundwinb += t*a
    sb += a
    t += 1

top = True
best = 0
win = 0
i = 0

for t in range(2*n):
    if top:
        win += t*A[i]
        endnow = win + roundwina
        if t%2 == 0:
            endnow += (2*n-1)*B[i]
    else:
        win += t*B[i]
        endnow = win + roundwinb
        if t%2 == 0:
            endnow += (2*n-1)*A[i]

    if t%2 == 1:
        i += 1
        if i != n:
            if top:
                roundwina -= A[i]*i + B[i]*(i+1 + 2*(n-i-1))
                roundwinb -= B[i]*(i+1) + A[i]*(i+2 + 2*(n-i-1))
                sa -= A[i] + B[i]
                sb -= A[i] + B[i]
                roundwina += sa*(t-1-i)
                roundwinb += sb*(t-1-i)
            else:
                roundwina -= A[i]*i + B[i]*(i+1 + 2*(n-i-1))
                roundwinb -= B[i]*(i+1) + A[i]*(i+2 + 2*(n-i-1))
                sa -= A[i] + B[i]
                sb -= A[i] + B[i]
                roundwina += sa*(t-1-i)
                roundwinb += sb*(t-1-i)
    else:
        top = not top

    best = max(best, endnow)
best = max(win,best)

print(best)
