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

R = lambda: map(int, input().split())
n = int(input())
arr = [list(R()), list(R())]
res = 0
i = j = cnt = 0
for c in range(2 * n):
    cnt += arr[i][j] * c
    if i == 0:
        j += 1
    else:
        j -= 1
    if j == n:
        i, j = 1, n - 1
res = max(res, cnt)
cnt = 0
i = 1; j = 0
for c in range(1, 2 * n):
    cnt += arr[i][j] * c
    if i == 1:
        j += 1
    else:
        j -= 1
    if j == n:
        i, j = 0, n - 1
res = max(res, cnt)
cnt = i = j = 0
for c in range(0, n):
    if c % 2 == 0:
        cnt += arr[0][c] * 2 * c + arr[1][c] * (2 * c + 1)
    else:
        cnt += arr[1][c] * 2 * c + arr[0][c] * (2 * c + 1)
res = max(res, cnt)
print(res)