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 sys import stdin
from itertools import repeat
def ts(a):
    n = len(a)
    ta = [0] * (n + 1)
    sa = [0] * (n + 1)
    for i in xrange(n - 1, -1, -1):
        sa[i] = sa[i+1] + ta[i+1]
        ta[i] = ta[i+1] + a[i]
    return sa, ta

def main():
    n = int(stdin.readline())
    a = map(int, stdin.readline().split(), repeat(10, n))
    b = map(int, stdin.readline().split(), repeat(10, n))
    if n == 1:
        print b[0]
        return
    rsa, ta = ts(a[::-1])
    sa, ta = ts(a)
    rsb, tb = ts(b[::-1])
    sb, tb = ts(b)
    ans = d = 0
    for i in xrange(n):
        t = d + sa[i] + rsb[i] + tb[i] * (n + i)
        if ans < t:
            ans = t
        d += i * 2 * a[i] + (i * 2 + 1) * b[i]
        a, b, sa, sb, ta, tb, rsa, rsb = b, a, sb, sa, tb, ta, rsb, rsa
    if ans < d:
        ans = d
    print ans
main()
