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 = input()
arr1 = map(int,raw_input().split(" "))
arr2 = map(int,raw_input().split(" "))
psum1 = [0]*n
psum2 = [0]*n
base1 = [0]*n
base2 = [0]*n


psum1[-1] = arr2[-1]
psum2[-1] = arr1[-1]
base1[-1] = arr2[-1]
base2[-1] = arr1[-1]

for i in range(n-1)[::-1]:
    psum1[i] = arr2[i] + arr1[i+1] + psum1[i+1]
    psum2[i] = arr1[i] + arr2[i+1] + psum2[i+1]  
for i in range(n-1)[::-1]:
    base1[i] = psum1[i+1] + arr1[i+1] + (2*(n-i-1)+1)*arr2[i] + base1[i+1]
    base2[i] = psum2[i+1] + arr2[i+1] + (2*(n-i-1)+1)*arr1[i] + base2[i+1]
 
maxv = 0
t = 0
ans = 0
for i in range(n):
    if i%2 == 0:
        ans += t*arr1[i]
        s = base1[i] + t*psum1[i] + ans
        t += 1
        ans += arr2[i]*t
    else:
        ans += t*arr2[i]
        s = base2[i] + t*psum2[i] + ans
        t += 1
        ans += arr1[i]*t
    t += 1    
    maxv = max(maxv,s)
 

print maxv
   		    	     	  	  	   		