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.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Mushrooms1016C {
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	void solve()
	{
		int n = ni();
		long sum123[][] = new long[2][n];
		long sum111[][] = new long[2][n];
		long sum321[][] = new long[2][n];
		long ud[][] = new long[2][n];
		
		int a[][] = new int[2][n];
		for(int i = 0 ; i<2 ; i++) 
			a[i] = na(n);
		
		long prev = 0;
		for(int i = 0 , j = 0 , ct = 0 ; i<n ; i++) {
			
			ud[j][i] = prev + ct*1l*a[j][i];
			prev = ud[j][i];
			ct++;
			if(i%2 == 0) {
				j++;
			}
			else {
				j--;
			}

			ud[j][i] = prev + ct*1l*a[j][i];
			prev = ud[j][i];
			ct++;		
		}
		
		for(int i = 0 ; i<2 ; i++) {
			for(int j = n - 1; j >= 0; --j) {
				sum123[i][j] = (j+1 == n ? 0 : sum123[i][j + 1]) + (j) * 1l * a[i][j];
				sum321[i][j] = (j+1 == n ? 0 : sum321[i][j + 1]) + (n - j - 1) * 1l * a[i][j];
				sum111[i][j] = (j+1 == n ? 0 : sum111[i][j + 1]) + a[i][j];
			} 
		}
		
		long res = 0;
		long max = 0;
//		
//		display2D(sum123);
//		display2D(sum321);
//		display2D(sum111);
		
		for(int i = 1 , j = 0 ; j<n ; j++ , i ^= 1) {
			
			long left = sum123[i^1][j] + sum111[i^1][j]*1l*j;
			
			long right = sum321[i][j] + sum111[i][j] * 1l *(n+j);
			
			res = left + (j-1 < 0 ? 0 : ud[i^1][j-1])+ right;
			
			//out.println(i+" "+j+" "+(j-1 < 0 ? 0 : ud[i^1][j-1])+" "+left + " " + right );
			max = Math.max(max, res);
		}
		
		out.println(max);
		
	}
	
	
	void run() throws Exception
	{
		is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);
		
		long s = System.currentTimeMillis();
		solve();
		out.flush();
		if(!INPUT.isEmpty())tr(System.currentTimeMillis()-s+"ms");
	}
	
	public static void main(String[] args) throws Exception { new Mushrooms1016C().run(); }
	
	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;
	
	private int readByte()
	{
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf){
			ptrbuf = 0;
			try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}
	
	private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
	private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }
	
	private double nd() { return Double.parseDouble(ns()); }
	private char nc() { return (char)skip(); }
	
	private String ns()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	
	private char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}
	
	private char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}
	
	private int[] na(int n)
	{
		int[] a = new int[n];
		for(int i = 0;i < n;i++)a[i] = ni();
		return a;
	}
	
	private int ni()
	{
		int num = 0, b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}
		
		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}
	
	private long nl()
	{
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}
		
		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}
	
	void display2D(int a[][]) {
		for(int i[] : a) {
			for(int j : i) {
				out.print(j+" ");
			}
			out.println();
		}
	}
	
	void display2D(long a[][]) {
		for(long i[] : a) {
			for(long j : i) {
				out.print(j+" ");
			}
			out.println();
		}
	}
	
	private static void tr(Object... o) { System.out.println(Arrays.deepToString(o)); }
}