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

way_1 = 0
way_2 = 0
way_3 = 0

for i in range(2 * n):
    if i < n:
        way_1 += a[i] * i
    else:
        way_1 += b[2 * n - i - 1] * i

for i in range(2 * n - 1):
    if i < n:
        way_2 += b[i] * (i + 1)
    else:
        way_2 += a[2 * n - i - 1] * (i + 1)

for i in range(2 * n):
    if i % 4 == 0:
        way_3 += a[i // 2] * i
    elif i % 4 == 1:
        way_3 += b[i // 2] * i
    elif i % 4 == 2:
        way_3 += b[i // 2] * i
    else:
        way_3 += a[i // 2] * i

print(max(way_1, way_2, way_3))