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

/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		BufferedReader br = new BufferedReader (new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine()); 
		StringTokenizer st = new StringTokenizer(br.readLine());
		StringTokenizer st1 = new StringTokenizer(br.readLine());
		int[] a = new int[n];
		int[] b = new int[n];
		for (int i=0; i<n; i++){
			a[i] = Integer.parseInt(st.nextToken());
			b[i] = Integer.parseInt(st1.nextToken());
		}
		int path1 = 0;
		int time = 0;
		for (time = 0; time<n; time++){
			path1 +=time*a[time];
		}
		for (int i=n-1; i>=0; i--){
			path1 += time*b[i];
			time++;
		}
		int path2 = 0;
		time = 1;
		for (int i = 0; i<n; i++){
			path2 +=(time)*b[i];
			time++;
		}
		for (int i=n-1; i>=0; i--){
			path2 += time*a[i];
			time++;
		}
		int path3 = 0;
		time = 0;
		path3 += 0*a[0] + 1*b[0] + 2*b[1] + 3*a[1];
		time = 4;
		for (int i = 2; i<n; i++){
			path3 +=time*a[i];
			time++;
		}
		for (int i=n-1; i>1; i--){
			path3 += time*b[i];
			time++;
		}
		int path = Math.max(path1,path2);
		path = Math.max(path,path3);
		System.out.println(path);

	}
}