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

import sys
from array import array


def readline(): return sys.stdin.buffer.readline().decode('utf-8')


n = int(readline())
a = [list(map(int, readline().split())) for _ in range(2)]

acc_m1 = [0]*(2*n+1)
acc1 = [0]*(2*n+1)
acc_m2 = [0]*(2*n+1)
acc2 = [0]*(2*n+1)

for i in range(n):
    acc_m1[i+1] = acc_m1[i] + a[0][i] * i
    acc1[i+1] = acc1[i] + a[0][i]

    acc_m2[i+1] = acc_m2[i] + a[1][i] * i
    acc2[i+1] = acc2[i] + a[1][i]

for i, j in zip(range(n-1, -1, -1), range(n, 2*n)):
    acc_m1[j+1] = acc_m1[j] + a[1][i] * j
    acc1[j+1] = acc1[j] + a[1][i]

    acc_m2[j+1] = acc_m2[j] + a[0][i] * j
    acc2[j+1] = acc2[j] + a[0][i]

x = 0
ans = 0

for i in range(n):
    if (i & 1) == 0:
        ans = max(
            ans,
            x + acc_m1[2*n-i] - acc_m1[i] + (acc1[2*n-i] - acc1[i]) * i
        )
        x += a[0][i] * (i*2) + a[1][i] * (i*2+1)
    else:
        ans = max(
            ans,
            x + acc_m2[2*n-i] - acc_m2[i] + (acc2[2*n-i] - acc2[i]) * i
        )
        x += a[1][i] * (i*2) + a[0][i] * (i*2+1)

print(ans)
