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


def arr_sum(arr):
    tem = [0]
    for i in range(len(arr)):
        tem.append(tem[i] + arr[i])
    return tem


rints = lambda: [int(x) for x in stdin.readline().split()]
n, a = int(input()), rints() + rints()[::-1]
mem1, mem2, cum, ans = [0], [0], arr_sum(a), 0

for i in range(n * 2):
    mem1.append(mem1[-1] + i * a[i])
    mem2.append(mem2[-1] + (i + 1) * a[-1 - i])

print(mem1, mem2)
tem = 0
for i in range(n):
    ix = i << 1
    if i & 1:
        v = tem + (mem2[-1 - i] - mem2[i]) + (i - 1) * (cum[-1 - i] - cum[i])
        ans = max(ans, v)
        tem += ix * a[-1 - i] + (ix + 1) * a[i]
    else:
        ans = max(ans, tem + (mem1[-1 - i] - mem1[i]) + i * (cum[-1 - i] - cum[i]))
        tem += ix * a[i] + (ix + 1) * a[-1 - i]

    # print(ans)
print(ans)
