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.*;
import java.io.*;

 
public class Main
{


	public static void main(String args[])
	{
		
		// int n,m;

		
	{
		
		Scanner sc= new Scanner(System.in);
		int n= sc.nextInt();
		int arr1[]= new int[n];
		// int pref1[]= new int[n];
		long suff1[]= new long[n];
		int arr2[]= new int[n];
		// int pref2[]= new int[n];
		long suff2[]= new long[n];

		for(int i=0;i<n;i++)
		{
			arr1[i]= sc.nextInt();
			// if(i==0)
			// 	pref1[i]=arr1[i];
			// else
			// 	pref1[i]=pref1[i-1]+arr1[i];
		}
		for(int i=0;i<n;i++)
		{
			arr2[i]= sc.nextInt();
			// if(i==0)
			// 	pref2[i]=arr2[i];
			// else
			// 	pref2[i]=pref2[i-1]+arr2[i];
		}

		for(int i=n-1;i>=0;i--)
		{
			if(i==n-1)
				suff1[i]=(long)arr1[i];
			else
				suff1[i]=(long)suff1[i+1]+(long)arr1[i];
		}

		for(int i=n-1;i>=0;i--)
		{
			if(i==n-1)
				suff2[i]=(long)arr2[i];
			else
				suff2[i]=suff2[i+1]+(long)arr2[i];
		}

		long dp[][][]= new long[n][2][2];
		dp[n-1][0][0]=(long)arr2[n-1];
		dp[n-1][1][0]=(long)arr1[n-1];

		long sums[][]= new long[n][2];
		sums[n-1][0]=(long)arr2[n-1];
		sums[n-1][1]= (long)arr1[n-1];

		for(int i=n-2;i>=0;i--)
		{
			sums[i][0]=sums[i+1][0]+suff1[i+1]+suff2[i+1]+(long)arr2[i]*(long)(2*(n-i)-1);
			sums[i][1]=sums[i+1][1]+suff1[i+1]+suff2[i+1]+(long)arr1[i]*(long)(2*(n-i)-1);

		}

		// System.out.println(sums[0][1]);
		for(int i=n-2;i>=0;i--)
		{
			dp[i][1][1]=dp[i+1][1][0]+suff1[i+1]+suff2[i+1];
			dp[i][0][1]=dp[i+1][0][0]+suff1[i+1]+suff2[i+1];

			long val1=sums[i][0] ;
			long val2= dp[i][1][1] + suff2[i] + suff1[i+1];

			

			dp[i][0][0]=Math.max(val1, val2);


			val1= sums[i][1];
			val2=  dp[i][0][1] +suff1[i]+ suff2[i+1];

			dp[i][1][0]=Math.max(val1, val2);
		}

		// for(int i=0;i<n;i++)
		// {
		// 	System.out.println(dp[i][0][0] + "  " + sums[i][0]);
		// }
		System.out.println(dp[0][0][0]);


	}
}

}











