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

l=lambda:map(int, input().split())
N=l()
a=list(l())
b=list(l())
t=0
mx=0
N=len(a)
for i in range(0, N):
    mx+=t*a[i]
    t+=1
for i in range(0, N):
    mx+=t*b[N-1-i]
    t+=1
cur=0
t=1
for i in range(0, N):
    cur+=t*b[i]
    t+=1
for i in range(0, N-1):
    cur+=t*a[N-1-i]
    t+=1

mx=max(mx, cur)
cur=0
i=1
j=0
t=1
while(1):
    if(i >= N & j >= N):
        break
    c=2
    while(c>0):
        c-=1
        if(j < N):
            cur+=t*b[j]
            j+=1
            t+=1
    c=2
    while(c > 0):
        c-=1
        if(i < N):
            cur+=t*a[i]
            t+=1
            i+=1
  #  print(i, j)
mx=max(cur, mx)
print(mx)
