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=list(map(int,input().split()))
b=list(map(int,input().split()))
sa1=[]
sa2=[]
sa3=[]
j=0
s=0
while(j<n):
    s+=a[j]*(j)
    j+=1
j=0
while(j<n):
    sa1.append(s)
    s-=a[j]*j
    j+=1
s=0
j=0
while(j<n):
    s+=a[j]*(n-j)
    j+=1
j=0
while(j<n):
    sa2.append(s)
    s -= a[j] * (n - j)
    j += 1

j=0
s=0
while(j<n):
    s+=a[j]
    j+=1
j=0
while(j<n):
    sa3.append(s)
    s-=a[j]
    j+=1

sb1=[]
sb2=[]
sb3=[]
j=0
s=0
while(j<n):
    s+=b[j]*(j)
    j+=1
j=0
while(j<n):
    sb1.append(s)
    s-=b[j]*j
    j+=1
s=0
j=0
while(j<n):
    s+=b[j]*(n-j)
    j+=1
j=0
p=0
while(j<n):
    sb2.append(s)
    s-=b[j]*(n-j)
    j += 1

j=0
s=0
while(j<n):
    s+=b[j]
    j+=1
j=0
while(j<n):
    sb3.append(s)
    s-=b[j]
    j+=1

ans=-1
ans=max(ans,sa1[0]+sb2[0]+(n-1)*sb3[0])
i=0
s=0
p=1
while(i<(n-1)):
    if (i%2)==0:
        s+=p*(b[i])
        ans=max(ans,s+sb1[i+1]+(p-i)*sb3[i+1]+sa2[i+1]+(p+n-1-i)*sa3[i+1])
        s+=(p+1)*(b[i+1])
        p+=2
    else:
        s+=p*a[i]
        ans = max(ans, s + sa1[i + 1] + (p - i) * sa3[i + 1] + sb2[i + 1] + (p + n - 1 - i) * sb3[i + 1])
        s+=(p+1)*(a[i+1])
        p+=2

    i+=1
print(ans)




