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

cdfa = [a[i]*i for i in xrange(n)]
cdfar = [a[i]*(n-i-1) for i in xrange(n)]
cdfb = [b[i]*i for i in xrange(n)]
cdfbr = [b[i]*(n-1-i) for i in xrange(n)]

ca, car, cb, cbr = 0, 0, 0, 0
for i in xrange(n-1,-1,-1):
    ca += cdfa[i]
    cdfa[i] = ca
    cb += cdfb[i]
    cdfb[i] = cb
    car += cdfar[i]
    cdfar[i] += car
    cbr += cdfbr[i]
    cdfbr[i] = cbr

pdfa, pdfb = [0 for i in xrange(n)], [0 for i in xrange(n)]
sa, sb = 0, 0
for i in xrange(n-1,-1,-1):
    sa += a[i]
    pdfa[i] = sa
    sb += b[i]
    pdfb[i] = sb

# only 2n possible routes since forced once straight
zigzag = 0
best = -1
for i in xrange(n): # start straight on ith column
    if i-1 >= 0: # update zigzag cost
        if (i-1)%2 == 0:
            zigzag += b[i-1] * (2*i-1)
        else:
            zigzag += a[i-1] * (2*i-1)
    # hook
    if i%2 == 0:
        costa = cdfa[i] + pdfa[i] * i # aj * j + ai * i = aj * 2i ->
        costb = cdfbr[i] + pdfb[i] * (2*i + (n-i))
    else:
        costb = cdfb[i] + pdfb[i] * i
        costa = cdfar[i] + pdfa[i] * (2*i + (n-i))
    cost = zigzag + costa + costb
    best = max(best, cost)
    # update zigzag
    if i%2 == 0:
        zigzag += a[i] * (2*i)
    else:
        zigzag += b[i] * (2*i)
    # hook, diff by 1 on way back now
    if i%2 == 0:
        costb = cdfb[i] + pdfb[i] * i
        if i < n-1:
            costa = cdfar[i+1] + pdfa[i+1] * (2*i + (n-i))
    else:
        costa = cdfa[i] + pdfa[i] * i # aj * j + ai * i = aj * 2i ->
        if i < n-1:
            costb = cdfbr[i+1] + pdfb[i+1] * (2*i + (n-i))
    cost = zigzag + costa + costb
    best = max(best, cost)
print best
