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.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class C {
    public static void main(String[] args) throws Exception {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        // Scanner scan = new Scanner(System.in);
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        int n = Integer.parseInt(bf.readLine());
        StringTokenizer st = new StringTokenizer(bf.readLine());
        long[] a = new long[n]; for(int i=0; i<n; i++) a[i] = Integer.parseInt(st.nextToken());
        st = new StringTokenizer(bf.readLine());
        long[] b = new long[n]; for(int i=0; i<n; i++) b[i] = Integer.parseInt(st.nextToken());

        long[] round_up = new long[n];
        long[] round_down = new long[n];

        long[] sum = new long[n];
        sum[n-1] = a[n-1] + b[n-1];
        for(int i=n-2; i>=0; i--) {
          sum[i] = sum[i+1] + a[i] + b[i];
        }

        round_up[n-1] = b[n-1];
        round_down[n-1] = a[n-1];
        int length = 2;
        for(int i=n-2; i>=0; i--) {
          length += 2;
          round_up[i] = (length-1)*b[i] + round_up[i+1] + sum[i+1];
          round_down[i] = (length-1)*a[i] + round_down[i+1] + sum[i+1];
        }

        long[] ans_up = new long[n];
        long[] ans_down = new long[n];
        ans_up[n-1] = round_up[n-1];
        ans_down[n-1] = round_down[n-1];
        length = 2;
        for(int i=n-2; i>=0; i--) {
          length += 2;
          ans_up[i] = Math.max(round_up[i], b[i] + 2*sum[i+1] + ans_down[i+1]);
          ans_down[i] = Math.max(round_down[i], a[i] + 2*sum[i+1] + ans_up[i+1]);
        }
        out.println(ans_up[0]);
      //  out.println(Arrays.toString(round_up));
        // int n = Integer.parseInt(st.nextToken());
        // int n = scan.nextInt();

        out.close(); System.exit(0);
    }
}
