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 = input()
a = map(int, raw_input().split())
b = map(int, raw_input().split())

sab = [0] * n
for i in reversed(range(n)):
    sab[i] = a[i] + b[i]
    if i + 1 < n: sab[i] += sab[i + 1]

szg = [0] * n
for i in range(n):
    szg[i] += (i * 2 + i % 2) * a[i]
    szg[i] += (i * 2 + (i + 1) % 2) * b[i]
    if i - 1 >= 0: szg[i] += szg[i - 1]
szg = [0] + szg

scw = [0] * n
for i in range(n):
    if i % 2 == 0:
        if i == 0:
            scw[i] = 0
            for j in range(n):
                scw[i] += j * a[j]
                scw[i] += (2 * n - j - 1) * b[j]
        else:
            pi = i * 2 - 4
            qi = 2 * n - 1
            scw[i] = scw[i - 2]
            scw[i] -= pi * a[i - 2] + (pi + 1) * a[i - 1]
            scw[i] -= qi * b[i - 2] + (qi - 1) * b[i - 1]
            scw[i] += 2 * sab[i]
            scw[i] -= szg[i - 2]
            scw[i] += szg[i]
    else :
        if i == 1:
            scw[i] = 0
            scw[i] += szg[i]
            for j in range(1, n):
                scw[i] += (j + 1) * b[j]
                scw[i] += (2 * (n - 1) - j + 2) * a[j]
        else:
            pi = i * 2 - 4
            qi = 2 * n - 1
            scw[i] = scw[i - 2]
            scw[i] -= pi * b[i - 2] + (pi + 1) * b[i - 1]
            scw[i] -= qi * a[i - 2] + (qi - 1) * a[i - 1]
            scw[i] += 2 * sab[i]
            scw[i] -= szg[i - 2]
            scw[i] += szg[i]

print max(scw)
