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

import java.io.*;
import java.util.*;


public class C {
    static BufferedReader inp = new BufferedReader(new InputStreamReader(System.in));
    static BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {

        int size = Integer.parseInt(inp.readLine());
        long[] up = new long[size];
        long[] down = new long[size];
        String[] s1 = inp.readLine().split(" ");
        String[] s2 = inp.readLine().split(" ");
        long sum = 0;
        long par = 0;
        long par1 = 0;
        long sum1 = 0;
        for(int i=0;i<size;i++){
            up[i] = Long.parseLong(s1[i]);
            down[i] = Long.parseLong(s2[i]);
            sum+=up[i]*i+down[i]*(2*size-i-1);
            par += up[i]+down[i];
            par1 = par;
            sum1+=up[i]*(2*size-i)+down[i]*(i+1);
        }

        long[][] dp = new long[size][2];
        sum1-=up[0]*2*size;
        dp[0][0] = 0;
        dp[0][1] = down[0]*1;
        long time = 2;

        long max = Math.max(sum,sum1);

        //System.out.println(max+" "+sum+" "+sum1);

        par -= up[0]+down[0];
        par1 = par;
        sum1-=down[0];
        sum-= down[0]*(2*size-1);

        //System.out.println(max+" "+sum+" "+sum1);

        for(int i=1;i<size;i++){
            //System.out.println(max+" "+sum+" "+sum1);
            if(i%2==1){
                dp[i][1] = dp[i-1][1]+down[i]*time;
                time++;
                dp[i][0] = dp[i][1]+up[i]*time;
                time++;
                par-=up[i]+down[i];
                sum-=up[i]*i+down[i]*(2*size-1-i);
                sum1-=up[i]*(2*size-i)+down[i]*(i+1);
                max = Math.max(max,dp[i][0]+((time-i-1)*par)+sum);
            }
            else{
                dp[i][0] = dp[i-1][0]+up[i]*time;
                time++;
                dp[i][1] = dp[i][0]+down[i]*time;
                time++;
                par-=up[i]+down[i];
                sum-=up[i]*i+down[i]*(2*size-1-i);
                sum1-=up[i]*(2*size-i)+down[i]*(i+1);
                max = Math.max(max,dp[i][1]+((time-i-2)*par)+sum1);
            }
            //System.out.println(max+" "+sum+" "+sum1+" "+par+" "+time);
            //System.out.println();

        }

       // print(dp);

        out.write(max+"\n");

        out.flush();


    }

    static void print(int[] array){
        for(int j=0;j<array.length;j++){
            System.out.print(array[j]+" ");
        }
        System.out.println();
    }
    static void print(int[][] array){
        for(int i=0;i< array.length;i++) {
            for (int j = 0; j < array[0].length; j++) {
                System.out.print(array[i][j] + " ");
            }
            System.out.println();
        }
    }
    static void print(boolean[] array){
        for(int j=0;j<array.length;j++){
            System.out.print(array[j]+" ");
        }
        System.out.println();
    }
    static void print(boolean[][] array){
        for(int i=0;i< array.length;i++) {
            for (int j = 0; j < array[0].length; j++) {
                System.out.print(array[i][j] + " ");
            }
            System.out.println();
        }
    }
    static void print(long[] array){
        for(int j=0;j<array.length;j++){
            System.out.print(array[j]+" ");
        }
        System.out.println();
    }
    static void print(long[][] array){
        for(int i=0;i< array.length;i++) {
            for (int j = 0; j < array[0].length; j++) {
                System.out.print(array[i][j] + " ");
            }
            System.out.println();
        }
    }
    static void print(String[] array){
        for(int j=0;j<array.length;j++){
            System.out.print(array[j]+" ");
        }
        System.out.println();
    }
    static void print(String[][] array){
        for(int i=0;i< array.length;i++) {
            for (int j = 0; j < array[0].length; j++) {
                System.out.print(array[i][j] + " ");
            }
            System.out.println();
        }
    }
}

