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

public class Main {
    static int N = 300005;
    static int n;
    static long ans;
    static long[][] a = new long[3][N];
    static long[] s1 = new long[N];
    static long[] s2 = new long[N];
    static long[] s3 = new long[N];
    static long[] s = new long[N];
    public static void main(String[] args) {
        Scanner reader = new Scanner(System.in);
        int i, j, t, m;
        n = reader.nextInt();
        for(i = 1; i <= 2; i++){
            for(j = 1; j <= n; j++) a[i][j] = reader.nextLong();
        }
        for(i = n; i >= 1; i--){
            s[i] = s[i + 1] + a[1][i] + a[2][i];
            s1[i] = a[2][i] * 2 * (i - 1) + a[1][i] * (2 * n - 1) + s1[i + 1] - s[i + 1];
            s2[i] = a[1][i] * 2 * (i - 1) + a[2][i] * (2 * n - 1) + s2[i + 1] - s[i + 1];
        }
        for(i = 1; i <= n; i++){
            if(i % 2 != 0) s3[i] = s3[i - 1] + a[1][i] * (2 * i - 2) + a[2][i] * (2 * i - 1);
            else s3[i] = s3[i - 1] + a[1][i] * (2 * i - 1) + a[2][i] * (2 * i - 2);
        }
        for(i = 0; i <= n; i++){
            if(i % 2 == 0) ans = Math.max(ans, s3[i] + s2[i + 1]);
            else ans = Math.max(ans, s3[i] + s1[i + 1]);
        }
        System.out.println(ans);
    }
}
		 						 	  	 	 	 	    	 				