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 {
	
	static long straight(int[][] glade, int n, int x, int y) {
		long ret=0;
		int start=y*2;
		for(int i=y;i<n;i++) {
			ret += glade[x][i]*start;
			ret += glade[-(x-1)][i]*(n*2-1-start);
			start++;
		}
		return ret;
	}
	
	static long go(int[][] glade,int n, int x, int y) {
		if(y==n) return 0;
		long a=straight(glade,n,x,y);
		long b=glade[x][y]*y*2+glade[-(x-1)][y]*(y*2+1)+go(glade,n,-(x-1),y+1);
		return Math.max(a,b);
	}
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[][] glade=new int[2][n];
		for(int i=0;i<2;i++)
			for(int j=0;j<n;j++)
				glade[i][j]=in.nextInt();
		
		System.out.println(go(glade,n,0,0));
		in.close();
	}
}