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=int(input())
a=[int(x) for x in input().split()]
b=[int(x) for x in input().split()]
an=0
for i in range(n):
    an+=a[i]*(i)
for j in range(n):
    p=n-1-j
    an+=b[p]*(n+j)
an12=0
dp=[a,b]
i=0
x=[[1,0],[0,1],[-1,0],[0,1]]
c=0

#print(dp)
j=0
p,q=0,0
while (q<n):
    an12+=dp[p][q]*c
   # print(p,q)
    p,q=p+x[j%4][0],q+x[j%4][1]
    j+=1
    c+=1
print(max(an12,an))