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.lang.*;
import java.io.*;

/*
 * 
 * Comments Here
 * 
 */
public class E49_C
{
	static BufferedReader br; 
	static BufferedWriter bw; 
	static StringTokenizer st;

	public static void main(String[] args) throws java.lang.Exception
	{
		br = new BufferedReader(new InputStreamReader(System.in));
		bw = new BufferedWriter(new OutputStreamWriter(System.out));
    		/*/
    		File file = new File("src/in.txt");
		try {
			br = new BufferedReader(FileReader(file));
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
		/**/
		
		
		int n = Integer.parseInt(br.readLine());
		
		long[][] shrooms = new long[2][n];
		
		st = new StringTokenizer(br.readLine());
		for(int i = 0; i < n; ++i) {
			shrooms[0][i] = Long.parseLong(st.nextToken());
		}
		
		st = new StringTokenizer(br.readLine());
		
		for(int i = 0; i < n; ++i) {
			shrooms[1][i] = Long.parseLong(st.nextToken());
		}
		
		long[][] dpl = new long[2][n];
		
		dpl[0][0]= 0;
		dpl[1][0] = shrooms[1][0];
		
		for(int i = 1; i < n; ++i) {
			
			//bottom to top
			if(i%2 == 1) {
				dpl[1][i] = dpl[1][i-1] + shrooms[1][i]*(long)(2*i);
				dpl[0][i] = dpl[1][i] + shrooms[0][i]*(long)(2*i+1);
			} else {
				dpl[0][i] = dpl[0][i-1] + shrooms[0][i]*(long)(2*i);
				dpl[1][i] = dpl[0][i] + shrooms[1][i]*(long)(2*i+1);
			}
			
			
		}
		
		
		long bestAns = Math.max(dpl[0][n-1], dpl[1][n-1]);
		
		
		
		long sum = 0;
		long resid = 0;
		int index = 2;
		for(int i = 0; i < 2*n; ++ i) {
			if(i < n) {
				sum += shrooms[0][i]*i;
				resid += shrooms[0][i];
				resid += shrooms[1][i];
			}
			else {
				sum += shrooms[1][2*n-i-1]*i;
			}
		}
		bestAns = Math.max(bestAns, sum);
		
		while(index < n-1) {
			
			//bw.write("sum " + sum + " resid " + resid + "\n");

			sum -= (index-2)*shrooms[0][index-2];
			sum -= (index-1)*shrooms[0][index-1];
			sum -= (2*n-2)*shrooms[1][index-1];
			sum -= (2*n-1)*shrooms[1][index-2];
			
			//bw.write("sum " + sum + " resid " + resid + "\n");

			
			resid -= shrooms[0][index-2];
			resid -= shrooms[0][index-1];
			resid -= shrooms[1][index-1];
			resid -= shrooms[1][index-2];
			
			sum += 2*resid;
			
			//bw.write("sum " + sum + " resid " + resid + "!\n");

		
			bestAns = Math.max(bestAns, sum+dpl[0][index-1]);
			index += 2;

		}
		
		
		sum = 0;
		resid = 0;
		index = 3;
		for(int i = 1; i < n; ++i) {
			resid += shrooms[0][i];
			resid += shrooms[1][i];
			sum += shrooms[0][i]*(2*n-i);
			sum += shrooms[1][i]*(i+1);
		}
		

		bestAns = Math.max(bestAns, sum + shrooms[1][0]);
		
		
		while(index < n-1) {
			

			sum -= (index-2)*shrooms[1][index-2];
			sum -= (index-1)*shrooms[1][index-1];
			sum -= (2*n-2)*shrooms[0][index-1];
			sum -= (2*n-1)*shrooms[0][index-2];
			

			
			resid -= shrooms[0][index-2];
			resid -= shrooms[0][index-1];
			resid -= shrooms[1][index-1];
			resid -= shrooms[1][index-2];
			
			sum += 2*resid;
			

		
			bestAns = Math.max(bestAns, sum+dpl[1][index-1]);
			index += 2;

		}
		
		
		
		bw.write(bestAns + "\n");
		
		
		br.close();
		bw.close();
	}
	

	
	
}

