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

#list_int 並べて出力 print (' '.join(map(str,ans_li)))
#list_str 並べて出力 print (' '.join(list))

# 2進数 format(10, 'b') # '1010'

''' 二次元配列を一列ずつ
for i in ans:
	print(*i)
'''
''' heapq
queue = []
heapq.heapify(queue) #heapqの作成
heapq.heappush(queue,num) #numのpush(値の追加)
pop = heapq.heappop(queue) #numのpop(最小値の出力)
pop = heapq.heappushpop(queue,num) #push -> pop

'''

from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

N = int(input())
grid = [0]*2
grid[0] = inpl()
grid[1] = inpl()

ans_L = [0]
SUM = 0
for i in range(1,N+1):
	if i%2 == 1:
		SUM += grid[0][i-1] * (i-1)*2
		SUM += grid[1][i-1] * (2*i-1)
	else:
		SUM += grid[1][i-1] * (i-1)*2
		SUM += grid[0][i-1] * (2*i-1)
	ans_L.append(SUM)

ans_R = [0]*(N+1)
SUM = 0
for i in range(N):
	SUM += grid[0][i]*i + grid[1][i]*(N*2-1-i)

rowsum = [0]*N
rSUM = 0
for i in reversed(range(N)):
	rSUM += grid[0][i]+grid[1][i]
	rowsum[i] = rSUM
rowsum.append(0)

last = 2*N-1
for i in range(0,N,2):
	ans_R[i] = SUM
	if i >= N-1: break
	start = last+1-(N-i)*2
	SUM -= grid[0][i]*start + grid[0][i+1]*(start+1)
	SUM -= grid[1][i]*last + grid[1][i+1]*(last-1)
	SUM -= rowsum[i+2]*2

SUM = 0
for i in range(1,N):
	SUM += grid[0][i]*(N*2-i) + grid[1][i]*(i+1)

last = 2*N-1
for i in range(1,N,2):
	ans_R[i] = SUM
	if i >= N-1: break
	start = last+1-(N-i)*2
	SUM -= grid[1][i]*start + grid[1][i+1]*(start+1)
	SUM -= grid[0][i]*last + grid[0][i+1]*(last-1)
	SUM -= rowsum[i+2]*2

ans = 0
for i in range(N+1):
	ans = max(ans,(ans_R[i]+ans_L[i]))

print(ans)
