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

   // package com.company;
    import java.util.*;
    public class Main {

        public static void main(String[] args) {
        // write your code here
            Scanner s=new Scanner(System.in);
            //System.out.println((int)'#');
        int n=s.nextInt();
        int[][] a=new int[2][n];
            //int[] b=new int[n];
for(int i=0;i<n;i++){
    a[0][i]=s.nextInt();
}
for(int i=0;i<n;i++){
    a[1][i]=s.nextInt();
}int i=0;int j=0;long sum=0;
while(i<n){
    sum+=j*a[0][i];
    j++;
    sum+=j*a[1][i];
    j++;i++;
    if(i<n){
        sum+=j*a[1][i];
        j++;
        sum+=j*a[0][i];
             j++;
    }i++;
}long sum1=0;
j=0;
i=0;
while(i<n){
    sum1+=j*a[0][i];j++;
    i++;
}i-=1;
while(i>=0){
            sum1+=j*a[1][i];j++;
i--;
}
long sum2=0;
sum2=a[1][0];
j=2;i=1;
while(i<n){
    sum2+=j*a[1][i];i++;j++;
}i-=1;
while(i>=0){
sum2+=j*a[0][i];i--;j++;
            }
            System.out.println(Math.max(sum,Math.max(sum1,sum2)));
        }
    }
