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(input())
a = [[int(i) for i in input().split()], [int(i) for i in input().split()]]
s = 0
value = [[0] * (n + 1), [0] * (n + 1)]
for i in reversed(range(n)):
    s += a[0][i] * i + a[1][i] * (2 * n - i - 1)
    value[1][i] = s

s = 0
for i in reversed(range(n)):
    s += a[1][i] * i + a[0][i] * (2 * n - i - 1)
    value[0][i] = s

ans = value[1][0]
count = 0
s = 0
for i in range(2 * n):
    if (2 <= (i + 1) % 4 <= 3):
        wk1 = 1
    else:
        wk1 = 0
    s += a[wk1][i // 2] * i
    ans = max(ans, s + value[wk1][(i + 1) // 2])

print(ans)
