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.Scanner;

public class Mushroom {

    public static void main(String[] args) {
        /*
        1 2 3 4 5
        6 7 8 9 10

        [
         */

        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[][] grid = new int[2][n];
        for (int row = 0; row < 2; row++) {
            for (int i = 0; i < n; i++) {
                grid[row][i] = in.nextInt();
            }
        }

        int[][] sum = new int[2][n + 1];
        for (int i = n - 1; i >= 0; i--) {
            for (int row = 0; row < 2; row++) {
                sum[row][i] += grid[row][i] + sum[row][i + 1];
            }
        }

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

        long[][] r2l = new long[2][n + 1];
        for (int i = n - 1; i >= 0; i--) {
            for (int row = 0; row < 2; row++) {
                r2l[row][i] += grid[row][i] * (n - 1 - i) + r2l[row][i + 1];
            }
        }

        long best = 0;
        long zigZag = 0;
        for (int col = 0; col < n; col++) {
            long score = 0;
            if (col % 2 == 0) { // top to bottom
                long topSeg = l2r[0][col];
                long botSeg = (n - col) * sum[1][col] + r2l[1][col];
                score = zigZag + col * 2 * (sum[0][col] + sum[1][col]) + (topSeg + botSeg);
                zigZag += grid[0][col] * col * 2 + grid[1][col] * (col * 2 + 1);
            } else { // bottom to top
                long botSeg = l2r[1][col];
                long topSeg = (n - col) * sum[0][col] + r2l[0][col];
                score = zigZag + col * 2 * (sum[0][col] + sum[1][col]) + (topSeg + botSeg);
                zigZag += grid[1][col] * (col * 2) + grid[0][col] * (col * 2 + 1);
            }

            best = Math.max(best, score);
        }

        System.out.println(best);
    }
}
