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 Main {
	
	private static long[] a = new long[300010];
	private static long[] b = new long[300010];
	
	private static long[] sum1 = new long[300010];
	private static long[] sum2 = new long[300010];
	private static long[] sum = new long[300010];
	
	private static boolean[][] vis = new boolean[3][300010];

	public static void main(String[] args) throws Exception {
	
		Scanner scan = new Scanner(System.in);
	
		int i , n = scan.nextInt();
		for (i = 0;i < n;i ++) {
			a[i] = scan.nextLong();
		}
		for (i = 0;i < n;i ++) {
			b[i] = scan.nextLong();
		}
		
		for (i = n - 1;i >= 0;i --) {
			if (i == n - 1) {
				sum[i] = a[i] + b[i];
			} else {
				sum[i] = sum[i + 1] + a[i] + b[i];
			}
		}
		
		// sum1, bottom to up
		for (i = n - 1;i >= 0;i --) {
			long total = (n - i) * 2;			
			if (i == n - 1) {
				sum1[i] = 0 * b[i] + 1 * a[i];
			} else {
				sum1[i] = 0 * b[i] + sum1[i + 1] + sum[i + 1] + (total - 1) * a[i];
			}
		}
		
		// sum2, up to bottom
		for (i = n - 1;i >= 0;i --) {
			long total = (n - i) * 2;
			if (i == n - 1) {
				sum2[i] = 0 * a[i] + 1 * b[i];
			} else {
				sum2[i] = 0 * a[i] + sum2[i + 1] + sum[i + 1] + (total - 1) * b[i];
			}
		}
		
		long ans = 0 , s = 0;
		int x = 0 , y = 0;
		for (i = 0;i < 2 * n;i ++) {
			vis[x][y] = true;
			// total
			if (x == 0) {
				if (vis[x + 1][y]) {
					s += (long) a[y] * i;
					y ++;
				} else {
					long temp = s + sum2[y] + (long) i * sum[y];
					if (temp > ans) {
						ans = temp;
					}
					s += (long) a[y] * i;
					x ++;
				}
			} else {
				if (vis[x - 1][y]) {
					s += (long) b[y] * i;
					y ++;
				} else {
					long temp = s + sum1[y] + (long) i * sum[y];
					if (temp > ans) {
						ans = temp;
					}
					s += (long) b[y] * i;
					x --;
				}
			}
		}
		if (s > ans) {
			ans = s;
		}
		System.out.println(ans);
		
	}
    
    
}














