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())
glade = [list(map(int,input().split(" "))),list(map(int,input().split(" ")))]
solution = 0
index = 2
#everything in glade times 2
doubles = 0

if n == 1:
	print(glade[1][0])
	exit()

temp = 0
temp += glade[1][0]

for i in range(n):
	solution += i * glade[0][i]
	solution += (2*n-i-1) * glade[1][i]
	doubles += (glade[0][i] * 2 + glade[1][i] * 2)
	temp += (1+i) * glade[1][i]
	temp += (2*n-i) * glade[0][i]

evenDoubles = doubles
curr = 0
prev = solution
while index <= n:
	curr = prev
	evenDoubles -= glade[0][index-2] * 2 + glade[0][index-1] * 2
	evenDoubles -= glade[1][index-2] * 2 + glade[1][index-1] * 2
	mult = (index-1) * 2
	curr -= glade[0][index-2] * (mult-2) + glade[0][index-1] * (mult-1)
	curr -= glade[1][index-2] * (2*n-1) + glade[1][index-1] * (2*n - 2)
	mult = 2 * index
	curr += glade[0][index-1] * (mult-1) + glade[1][index-1] * (mult-2)
	curr += glade[1][index-2] * (mult-3) + glade[0][index-2] * (mult-4)
	curr += evenDoubles
	if curr > solution:
		solution = curr
	prev = curr
	index += 2


if temp > solution:
	solution = temp
doubles -= (glade[0][0] * 2 + glade[1][0] * 2)
index = 3
prev = temp
curr = 0
while index <= n:
	curr = prev
	doubles -= glade[0][index-2] * 2 + glade[0][index-1] * 2
	doubles -= glade[1][index-2] * 2 + glade[1][index-1] * 2
	mult = (index-1) * 2
	curr -= glade[1][index-2] * (mult-2) + glade[1][index-1] * (mult-1)
	curr -= glade[0][index-2] * (2*n-1) + glade[0][index-1] * (2*n - 2)
	mult = 2 * index
	curr += glade[1][index-1] * (mult-1) + glade[0][index-1] * (mult-2)
	curr += glade[0][index-2] * (mult-3) + glade[1][index-2] * (mult-4)
	curr += doubles
	if curr > solution:
		solution = curr
	prev = curr
	index += 2

print(solution)
	






	
	

	
