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(j) for j in input().split()]
b = [int(j) for j in input().split()]
c1 = c2 = c3 = 0
k = 0
for i in range(n):
	c1 += k * a[i]
	c3 += (k + 1) * b[i]
	k += 1
for i in range(n-1 , -1, -1):
	c1 += k * b[i]
	if i != 0:
		c3 += (k + 1) * a[i]
	k += 1
k = 1
p = 1
q = 0
x = [0] * n
y = [0] * n
for i in range(n // 2 + 1):
	if 2 * i < n:
		y[2 * i] = k
	if 2 * i + 1 < n:
		y[2 * i + 1] = k + 1
	k += 4
k = 3
for i in range(1, n // 2 + 1):
	if 2 * i - 1 < n:
		x[2 * i - 1] = k
	if 2 * i < n:
		x[2 * i] = k + 1
	k += 4
for i in range(n):
	c2 += x[i] * a[i] + y[i] * b[i]
print(max(c1, c2, c3))
