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

public class c{ 

	static void solve(){ 
		int n = ni();
		long[][] a = new long[2][n];
		for(int i=0;i<n;++i)a[0][i]=nl();
		for(int i=0;i<n;++i)a[1][i]=nl();


		long[] ue = new long[n];
		ue[n-1] = a[0][n-1]*(n-1) + a[1][n-1]*n;
		for(int i=n-2;i>=0;--i)ue[i] = ue[i+1] + a[0][i]*i + a[1][i]*(2*n-1-i);
		long[] sum = new long[n];
		sum[n-1] = a[0][n-1] + a[1][n-1];
		for(int i=n-2;i>=0;--i)sum[i] = sum[i+1] + a[0][i] + a[1][i];

		long[] sita = new long[n];
		sita[n-1] = a[1][n-1]*(n) + a[0][n-1]*(n+1);
		for(int i=n-2;i>=0;--i)sita[i] = sita[i+1] + a[1][i]*(i+1) + a[0][i]*(2*n-i);

		long ans = 0;
		long cur = 0;
		for(int i=0;i<n;++i){
			if(i%2==0){
//				out.println(cur + ue[i] + sum[i]*i);
				ans = Math.max(ans, cur + ue[i] + sum[i]*i);
				cur += (2*i)*a[0][i] + (2*i+1)*a[1][i];
			}else{
//				out.println(cur + sita[i] + sum[i]*(i-1));
				ans = Math.max(ans, cur + sita[i] + sum[i]*(i-1));
				cur += (2*i)*a[1][i] + (2*i+1)*a[0][i];
			}
		}

		out.println(ans);

 
	} 
 
 
 
 
	public static void main(String[] args){ 
		 solve(); 
		 out.flush(); 
	 } 
	 private static InputStream in = System.in; 
	 private static PrintWriter out = new PrintWriter(System.out); 
 
	 private static final byte[] buffer = new byte[1<<15]; 
	 private static int ptr = 0; 
	 private static int buflen = 0; 
	 private static boolean hasNextByte(){ 
		 if(ptr<buflen)return true; 
		 ptr = 0; 
		 try{ 
			 buflen = in.read(buffer); 
		 } catch (IOException e){ 
			 e.printStackTrace(); 
		 } 
		 return buflen>0; 
	 } 
	 private static int readByte(){ if(hasNextByte()) return buffer[ptr++]; else return -1;} 
	 private static boolean isSpaceChar(int c){ return !(33<=c && c<=126);} 
	 private static int skip(){int res; while((res=readByte())!=-1 && isSpaceChar(res)); return res;} 
 
	 private static double nd(){ return Double.parseDouble(ns()); } 
	 private static char nc(){ return (char)skip(); } 
	 private static String ns(){ 
		 StringBuilder sb = new StringBuilder(); 
		 for(int b=skip();!isSpaceChar(b);b=readByte())sb.append((char)b); 
		 return sb.toString(); 
	 } 
	 private static int[] nia(int n){ 
		 int[] res = new int[n]; 
		 for(int i=0;i<n;++i)res[i]=ni(); 
		 return res; 
	 } 
	 private static long[] nla(int n){ 
		 long[] res = new long[n]; 
		 for(int i=0;i<n;++i)res[i]=nl(); 
		 return res; 
	 } 
	 private static int ni(){ 
		 int res=0,b; 
		 boolean minus=false; 
		 while((b=readByte())!=-1 && !((b>='0'&&b<='9') || b=='-')); 
		 if(b=='-'){ 
			 minus=true; 
			 b=readByte(); 
		 } 
		 for(;'0'<=b&&b<='9';b=readByte())res=res*10+(b-'0'); 
		 return minus ? -res:res; 
	 } 
	 private static long nl(){ 
		 long res=0,b; 
		 boolean minus=false; 
		 while((b=readByte())!=-1 && !((b>='0'&&b<='9') || b=='-')); 
		 if(b=='-'){ 
			 minus=true; 
			 b=readByte(); 
		 } 
		 for(;'0'<=b&&b<='9';b=readByte())res=res*10+(b-'0'); 
		 return minus ? -res:res; 
	} 
} 

