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

import sys
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
if n==1:
    print(b[0])
    sys.exit(0)
l1=[0]*n
l2=[0]*n
s=[0]*n
s[-1]=a[-1]+b[-1]
l1[n-1]=b[-1]
l2[-1]=a[-1]
for i in range(n-2,-1,-1):
    l1[i]=l1[i+1]+b[i]*(1+(n-i-1)*2)+s[i+1]
    s[i]=s[i+1]+a[i]+b[i]
    l2[i]=l2[i+1]+a[i]*(1+(n-i-1)*2)+s[i+1]

m=l1[0]
t=0
ps=0
for i in range(0,n,2):
    a1=0
    a1=l1[i]+ps+s[i]*t
    if i+1<n:
        ps=ps+b[i]*(t+1)+b[i+1]*(t+2)+a[i+1]*(t+3)
    t+=4
    #print(a1)
    m=max(m,a1)
    
t=2
ps=b[0]
for i in range(1,n,2):
    a1=0
    a1=l2[i]+ps+s[i]*t
    if i+1<n:
        ps=ps+b[i]*(t)+a[i]*(t+1)+a[i+1]*(t+2)+b[i+1]*(t+3)
    t+=4
    #print(a1)
    m=max(m,a1)
print(m)
