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

public class C implements Runnable{
	public static void main (String[] args) {new Thread(null, new C(), "_cf", 1 << 28).start();}

	public void run() {
//		try { new TestGenerator(); } catch (Exception e) {}
		FastScanner fs = new FastScanner();
//		try { fs = new FastScanner("testdata.out"); } catch (Exception e) {}
		PrintWriter out = new PrintWriter(System.out);
		System.err.println("Go!");

		int n = fs.nextInt();
		int[][] a = new int[2][n];
		for(int i = 0; i < 2; i++)
			a[i] = fs.nextIntArray(n);
		
		if(n == 1) {
			out.println(a[1][0]);
			out.close();
			return;
		}
		
		long[] sums = new long[n];
		sums[n-1] = a[1][n-1]+a[0][n-1];
		for(int i = n-2; i >= 0; i--)
			sums[i] = sums[i+1] + a[1][i]+a[0][i];
		
		long[][] vs1 = new long[2][n];
		long x = 0;
		for(int j = 1, time = 2; j >= 0; j--) {
			if(j == 1) {
				for(int i = 1; i < n; i++, time++) {
					x += (long)(time)*a[j][i];
					vs1[j][i] = (long)(time)*a[j][i];
				}
			}
			else {
				for(int i = n-1; i > 0; i--, time++) {
					x += (long)(time)*(a[j][i]);
					vs1[j][i] = (long)(time)*a[j][i];
				}
			}
		}
		long[] bottom = new long[n];
		bottom[0] = x;
		for(int i = 2, freq = 0; i < n; i += 2) {
			//delete the contribution of i and i-1
			for(int k = 0; k < 2; k++) {
				for(int j = i - 1; j <= i; j++) {
					x -= vs1[k][j] + (long)freq*a[k][j];
				}
			}
			freq += 2;
			long pref = i+1 < n ? sums[i+1] : 0;
			x += 2L*pref;
			bottom[i] = x;
		}

		long[] top = new long[n];
		long[][] vs2 = new long[2][n];
		long y = 0;
		for(int j = 0, time = 4; j < 2; j++) {
			if(j == 0) {
				for(int i = 2; i < n; i++, time++) {
					y += (long)time * a[j][i];
					vs2[j][i] = (long)time * a[j][i];
				}
			}
			else {
				for(int i = n-1; i > 1; i--, time++) {
					y += (long)time * a[j][i];
					vs2[j][i] = (long)time * a[j][i];
				}
			}
		}
		top[1] = y;
		for(int i = 3, freq = 0; i < n; i += 2) {
			for(int k = 0; k < 2; k++) {
				for(int j = i - 1; j <= i; j++) {
					y -= vs2[k][j] + (long)freq*a[k][j];
				}
			}
			freq += 2;
			long pref = i + 1 < n ? sums[i+1] : 0;
			y += 2L*pref;
			top[i] = y;
		}

//		System.out.println(Arrays.toString(top));
//		System.out.println(Arrays.toString(bottom));
		
		long res = 0;
		long sum = 0;
		int z = 0;
		for(int i = 0, time = 0; i < n; i++) {
			sum += (long)(time++)*a[z][i];
			if(z == 0)
				res = Math.max(res, sum+top[i]);
			else
				res = Math.max(res, sum + bottom[i]);

//			System.out.println(i + " " + z + " " + sum);
			
			sum += (long)(time++)*a[z^1][i];
			if(z == 0)
				res = Math.max(res, sum+bottom[i]);
			else
				res = Math.max(res, sum+top[i]);
			
//			System.out.println(i + " " + z + " " + sum);
//			System.out.println();
			
			z ^= 1;
		}
		
		long ret = 0;
		for(int j = 0, time = 0; j < 2; j++) {
			if(j == 0) {
				for(int i = 0; i < n; i++, time++) {
					ret += (long)(time)*a[j][i];
				}
			}
			else {
				for(int i = n-1; i >= 0; i--, time++) {
					ret += (long)(time)*a[j][i];
				}
			}
		}
		res = Math.max(res, ret);
		out.println(res);
		
//		out.println(rec(0, 0, n, 0, a, new boolean[2][n]));
		
		out.close();
	}
	
	int[] dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};
	
	long rec(int x, int y, int n, int time, int[][] a, boolean[][] vis) {
		vis[x][y] = true;
		long res = time*a[x][y];
		long run = 0;

//		boolean print = x == 0 && y == 2;
		for(int d = 0; d < 4; d++) {
			int nx = x + dx[d];
			int ny = y + dy[d];
			if(!good(nx, ny, n)) continue;
			if(vis[nx][ny]) continue;
			vis[nx][ny] = true;
			long ret = rec(nx, ny, n, time+1, a, vis);
//			if(ret == 1094 && print) {
//				System.out.println(nx + " " + ny + " " + time);
//			}
			run = Math.max(run, ret);
			vis[nx][ny] = false;
		}
		vis[x][y] = false;
//		if(print) {
//			System.out.println("R " + run);
//		}
		return res+run;
	}
	
	boolean good(int x, int y, int n) {
		return x >= 0 && y >= 0 && x < 2 && y < n;
	}

	class FastScanner {
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public FastScanner() {
			in = new BufferedInputStream(System.in, BS);
		}

		public FastScanner(String s) throws FileNotFoundException {
			in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}                
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
			double cur = nextLong();
			return c!='.' ? cur:cur+nextLong()/num;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}
		
		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for(int i = 0; i < n; i++) res[i] = nextInt();
			return res;
		}
		
	}

}