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 B{
	public static void main(String[] args)
	{
		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = fs.nextInt();
		long[][] arr = new long[2][n];
		for(int i=0;i<n;i++)arr[0][i] = fs.nextLong();
		for(int i=0;i<n;i++)arr[1][i] = fs.nextLong();
		long[] pre = new long[n];
		int start = 0;
		int cur = 0;
		for(int i=0;i<n;i++)
		{
			if(i>0)pre[i] = pre[i-1];
			pre[i] += arr[cur][i]*start + arr[cur^1][i]*(start+1);
			cur ^= 1;
			start += 2;
		}
//		for(long i:pre)out.print(i+" ");
//		out.println();
		long[][] sum123 = new long[2][n+1];
		long[][] sum321 = new long[2][n+1];
		long[][] sum111 = new long[2][n+1];
		
		for(int i=0;i<2;i++)
		{
			for(int j=n-1;j>=0;j--)
			{
				sum123[i][j] = sum123[i][j+1] + arr[i][j]*j;
				sum321[i][j] = sum321[i][j+1] + arr[i][j]*(n-1-j);
				sum111[i][j] = sum111[i][j+1] + arr[i][j];
			}
		}
		long prev = 0; long ans = 0;
		for(int i=0,j=0;j<n;j++,i^=1)
		{
			long my = prev;
			my += sum123[i][j] + j*sum111[i][j];
//			out.println(j+" "+my);
			my += sum321[i^1][j] + (n+j)*sum111[i^1][j];
//			out.println(j+" "+my);
			ans = Math.max(ans,my);
			prev = pre[i];
//			out.println(ans);
		}
		out.println(ans);
		out.close();
	}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
	public static int[] sort(int[] arr)
	{
		List<Integer> temp = new ArrayList();
		for(int i:arr)temp.add(i);
		Collections.sort(temp,Collections.reverseOrder());
		int start = 0;
		for(int i:temp)arr[start++]=i;
		return arr;
	}
	public static char[] rev(char[] arr)
	{
		char[] ret = new char[arr.length];
		int start = arr.length-1;
		for(char i:arr)ret[start--] = i;
		return ret;
	}
}