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())
r1 = list(map(int, input().split()))
r2 = list(map(int, input().split()))
w1, w2 = [0]*(n+1), [0]*(n+1)
for i in range(1, n+1):
    if i%2 == 0:
        w1[i] = w1[i-1] + r2[i-1]*(i*2 - 2) + r1[i-1]*(i*2 - 1)
    else:
        w1[i] = w1[i-1] + r1[i-1]*(i*2 - 2) + r2[i-1]*(i*2 - 1)
for i in range(n-2, -1, -1):
    if i%2 == 1:
        w2[i] = w2[i+2] + r2[i]*i + r2[i+1]*(i+1) + r1[i]*(2*n-i) + r1[i+1]*(2*n-i-1)
    else:
        w2[i] = w2[i+2] + r1[i]*i + r1[i+1]*(i+1) + r2[i]*(2*n-i) + r2[i+1]*(2*n-i-1)
print(w1, w2)
weight = 0
for i in range(0, n+1):
    weight = max(weight, w1[i] + w2[i])
    print(i, w1[i], w2[i], w1[i] + w2[i])
print(weight)
