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

def fu(xi,xf,val):
    suma1=0
    for i in range(xi,n):
        suma1+=val*(l1[i])
        val+=1
    for j in range(n-1,xf-1,-1):
        suma1+=val*(l2[j])
        val+=1
    return suma1
    
def fd(xi,xf,val):
    suma1=0
    for i in range(xi,n):
        suma1+=val*(l2[i])
        val+=1
    for j in range(n-1,xf-1,-1):
        suma1+=val*(l1[j])
        val+=1
    return suma1    

n=int(input())
l1=list(map(int,input().split()))
l2=list(map(int,input().split()))

maxi=fu(0,0,0)
maxi=max(maxi,fd(0,0,0))
suma,mul=0,0
#print(maxi)
cnt=0
for i in range(n):
    if cnt%2==0:
        if i%2==0 and i>0:
            maxi=max(suma+fu(i,i,mul),maxi)
        suma+=mul*l1[i]
        mul+=1
        suma+=mul*(l2[i])
        mul+=1
    else:
        if i%2!=0:
            maxi=max(suma+fd(i,i,mul),maxi)
        suma+=mul*(l2[i])
        mul+=1
        suma+=mul*(l1[i])
        mul+=1
    cnt+=1    
print(max(maxi,suma))    

