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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;

public class Main {
	static int maxn=(int) (6e5+50);
	static long a[]=new long[maxn];
	static long b[]=new long[maxn];
	static long sum_pre[]=new long[maxn];//第i-n列(a[],b[])的总和
	static long sum_s[]=new long[maxn];//sum_s[i]表示顺时针前缀和(从a[1]~a[n]再到b[n]~b[1])且乘上步数i
	static long sum_n[]=new long[maxn];//逆时针统计前缀和
	static long suml[]=new long[maxn];
	static long sumr[]=new long[maxn];
	static int n;
	static StreamTokenizer st=new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));	
	public static void main(String[] args) {
		n=nextInt();
		for(int i=1;i<=n;i++)
			a[i]=nextInt();
		for(int i=1;i<=n;i++)
			b[i]=nextInt();
		//预处理需要的前缀和
		for(int i=n;i>=1;i--)
			sum_pre[i]=sum_pre[i+1]+a[i]+b[i];
		for(int i=1;i<=n;i++){
			sum_s[i]=sum_s[i-1]+a[i]*(i-1);
			sum_n[i]=sum_n[i-1]+b[i]*(i-1);
		}
		for(int i=n;i>=1;i--){
			sum_s[2*n-i+1]=sum_s[2*n-i]+b[i]*(2*n-i);
			sum_n[2*n-i+1]=sum_n[2*n-i]+a[i]*(2*n-i);
		}
		for(int i=1;i<=n;i++){
			if(i%2==1){
				sumr[i]=sum_s[2*n+1-i]-sum_s[i-1]+(i-1)*sum_pre[i];
				suml[i]=suml[i-1]+a[i-1]*(2*i-3)+b[i-1]*(2*i-4);
			}else{
				sumr[i]=sum_n[2*n+1-i]-sum_n[i-1]+(i-1)*sum_pre[i];
				suml[i]=suml[i-1]+a[i-1]*(2*i-4)+b[i-1]*(2*i-3);
			}
		}
		long ans=0;
		for(int i=1;i<=n;i++)
			ans=Math.max(ans, suml[i]+sumr[i]);
		System.out.println(ans);
	}
	static int nextInt(){
		try {
			st.nextToken();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return (int)st.nval;
	}
}
