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 f(a):
    n = len(a)
    ta = [0] * (n + 1)
    sa = [0] * (n + 1)
    ra = [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]
        ra[i] = ra[i+1] + (n - 1 - i) * a[i]
    return sa, ta, ra
def main():
    n = int(stdin.readline())
    a = [map(int, stdin.readline().split(), repeat(10, n)) for _ in xrange(2)]
    b = map(f, a)
    ans = j = d = 0
    for i in xrange(n):
        t = d + b[j][0][i] + b[j^1][2][i] + b[j^1][1][i] * (n + i) + b[j][1][i] * 2 * i
        if ans < t:
            ans = t
        d += i * 2 * a[j][i] + (i * 2 + 1) * a[j^1][i]
        j ^= 1
    if ans < d:
        ans = d
    print ans
main()
