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 C {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] grid = new int[2][n];
        long[] rsum = new long[n];
        for (int i = 0; i < n; i++) {
            grid[0][i] = sc.nextInt();
            rsum[i] = grid[0][i];
        }
        for (int i = 0; i < n; i++) {
            grid[1][i] = sc.nextInt();
            rsum[i] += grid[1][i];
        }
        rsum[n-1] = grid[0][n-1] + grid[1][n-1];
        for (int i = n-2; i >=0; i--) {
            rsum[i] = rsum[i+1] + grid[0][i] + grid[1][i];
        }
        long[][] dpr = new long[2][n];
        dpr[0][n-1] = grid[1][n-1];
        dpr[1][n-1] = grid[0][n-1];
        for (int i = n-2; i >=0; i--) {
            dpr[0][i] = dpr[0][i+1] + rsum[i+1] + (2*(n-i)-1)*grid[1][i];
            dpr[1][i] = dpr[1][i+1] + rsum[i+1] + (2*(n-i)-1)*grid[0][i];
        }

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

        long max = Math.max(dpr[0][0], dpl[n-1]);
        for (int i = 1; i < n; i++) {
            long p = dpl[i-1] + dpr[i%2][i] + rsum[i]*2*i;
            max = Math.max(max, p);
        }
        System.out.println(max);
    }
}
