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()))
upper_lst=[0 for i in range(n+1)]
lower_lst=[0 for i in range(n+1)]
count_u,count_l=0,0
count=1
pre_total=0
upper_sum=a[::]
lower_sum=b[::]
for i in range(n-2,-1,-1):
    upper_sum[i] +=upper_sum[i+1]
    lower_sum[i] +=lower_sum[i+1]
for i in range(n-1,-1,-1):
    upper_lst[i] =b[i] *count +pre_total +upper_lst[i+1]
    lower_lst[i] =a[i] *count +pre_total +lower_lst[i+1]
    pre_total += a[i] +b[i]
    count+=2
maxi=0
total=0
count=0
for i in range(n):
    if i% 2==0:
        maxi =max(maxi,upper_lst[i] +total +(count ) *(upper_sum[i] +lower_sum[i]))
        total +=a[i] *count +b[i]*(count+1)
    else:
        maxi=max(maxi,lower_lst[i] +total +(count ) *(upper_sum[i] +lower_sum[i]))
        total +=b[i] *count +a[i]*(count +1)
    count +=2
print(maxi)