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 Contest501div2;

import java.util.Arrays;
import java.util.Scanner;

public class main501C {
    public static Scanner enter = new Scanner(System.in);
    public static void main(String[] args) {
        int n= enter.nextInt();
        long max=0;
        long[][] mass = new long[2][n];
        for (int j = 0; j <2 ; j++) {
            for (int i = 0; i <n ; i++) {
                mass[j][i]=enter.nextInt();
                max+=((1-j)*i+j*(2*n-i-1))*mass[j][i];
            }
        }
        mass[0][0]=0;
        //System.out.println(max);
        long[] up123 = new long[n];
        up123[n-1]=(n-1)*mass[0][n-1];
        long[] up321 = new long[n];
        up321[n-1]=mass[0][n-1];
        long[] up111 = new long[n];
        up111[n-1]=mass[0][n-1];
        for (int i = n-2; i>=0 ; i--) {
            up123[i]+=up123[i+1]+(i)*mass[0][i];
            up321[i]+=up321[i+1]+(n-i)*mass[0][i];
            up111[i]+=up111[i+1]+mass[0][i];
        }
        long[] down123 = new long[n];
        down123[n-1]=(n-1)*mass[1][n-1];
        long[] down321 = new long[n];
        down321[n-1]=mass[1][n-1];
        long[] down111 = new long[n];
        down111[n-1]=mass[1][n-1];
        for (int i = n-2; i>=0 ; i--) {
            down123[i]+=down123[i+1]+(i)*mass[1][i];
            down321[i]+=down321[i+1]+(n-i)*mass[1][i];
            down111[i]+=down111[i+1]+mass[1][i];
        }
        long tmp=0;
        long summ=0;
        for (int i = 1; i <=n-1 ; i++) {
            int position=i-1;
            int last=n-position-1;
            int way=2*i-1;
            if(i%2==0){
                tmp+=mass[0][position]*way+mass[1][position]*(way-1);
                summ+=up123[position+1]+up111[position+1]*(way-position)+down321[position+1]+down111[position+1]*(way+last)+tmp;
            }
            else{
                tmp+=mass[1][position]*way+mass[0][position]*(way-1);
                summ+=down123[position+1]+down111[position+1]*(way-position)+up321[position+1]+up111[position+1]*(way+last)+tmp;
            }
            ///System.out.println(summ+" "+i);
            max=Math.max(max,summ);
            summ=0;

        }
        System.out.println(max);

    }
}
