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.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.ArrayDeque;

public class C {

	static int R = 2;
	static int C;
	static long g[][];
	static long best = 0;
	public static void main(String[] args) {
		JS in = new JS();
		C = in.nextInt();
		g = new long[R][C];
		for(int i = 0; i < R; i++) {
			for(int j = 0; j < C; j++) g[i][j] = in.nextLong();
		}
		long cumSumR1[] = new long[C];
		long cumSumR2[] = new long[C];
		cumSumR1[0] = g[0][0];
		for(int i = 1; i < C; i++) cumSumR1[i] = cumSumR1[i-1]+g[0][i];
		cumSumR2[0] = g[1][0];
		for(int i = 1; i < C; i++) cumSumR2[i] = cumSumR2[i-1]+g[1][i];
		
		
		long sumR1_1[] = new long[C];
		long sumR2_1[] = new long[C];
		sumR1_1[0] = 0;
		for(int i = 1; i < C; i++) {
			sumR1_1[i] = sumR1_1[i-1]+g[0][i]*i;
		}
		
		sumR2_1[0] = g[1][C-1]*(long)(C);
		int id = 1;
		long mult = C+1;
		for(int i = C-2; i >= 0; i--) {
			sumR2_1[id] = sumR2_1[id-1]+g[1][i]*mult;
			id++;
			mult++;
		}
		
		long sumR1_2[] = new long[C];
		long sumR2_2[] = new long[C];
		sumR2_2[0] = g[1][0];
		for(int i = 1; i < C; i++) {
			sumR2_2[i] = sumR2_2[i-1] + g[1][i]*(i+1);
		}
		sumR1_2[0] = g[0][C-1]*(long)(C+1);
		id = 1;
		mult = C+2;
		for(int i = C-2; i >= 0; i--) {
			sumR1_2[id] = sumR1_2[id-1] + g[0][i]*mult;
			id++;
			mult++;
		}
		
		best = 0;
		ArrayDeque<state> q = new ArrayDeque<state>();
		q.add(new state(0,0,0,0));
		while(!q.isEmpty()) {
			state v = q.poll();
			if(v.c == C-1) {
				if((C%2 == 0 && v.r == 0) || (C%2==1&&v.r==1) ) {
					best = Math.max(best, v.mush);
					break;
				}
			}
			if(v.r == 0) {
				if(v.c%2 == 0) { //go down at the end and calc
					long res1 = sumR1_1[C-1] - sumR1_1[v.c];
					long et1 = (v.time+1) - (v.c+1);
					long cSum1 = cumSumR1[C-1] - cumSumR1[v.c];
					res1 += (cSum1*et1);
					
					long res2 = sumR2_1[C-1-v.c];
					long et2 = (v.time+(C-v.c)) - (C);
					long cSum2 = cumSumR2[C-1] - (v.c==0? 0 : cumSumR2[v.c-1]);
					res2 += (cSum2*et2);
					best = Math.max(best, v.mush+res1+res2);
					
					
					q.add(new state(1,v.c,v.time+1,v.mush + g[1][v.c]*(v.time+1)));
				}
				else { //go right at the end
					q.add(new state(0,v.c+1,v.time+1,v.mush + g[0][v.c+1]*(v.time+1)));
				}
			}
			else {
				if(v.c%2 == 0) { //go right at the end
					q.add(new state(1,v.c+1,v.time+1,v.mush + g[1][v.c+1]*(v.time+1)));
				}
				else {	//go up at the end and calc
					long res1 = sumR2_2[C-1] - sumR2_2[v.c];
					long et1 = (v.time+1) - (v.c+2);
					long cSum1 = cumSumR2[C-1] - cumSumR2[v.c];
					res1 += (cSum1*et1);
					
					long res2 = sumR1_2[C-1-v.c];
					long et2 = (v.time+(C-v.c)) - (C+1);
					long cSum2 = cumSumR1[C-1] - (v.c==0? 0 : cumSumR1[v.c-1]);
					res2 += (cSum2*et2);
					best = Math.max(best, v.mush+res1+res2);
					
					
				
					q.add(new state(0,v.c,v.time+1,v.mush+g[0][v.c]*(v.time+1)));
				}
			}
			
			
		}
		System.out.println(best);
			
		
		
	}
	
	static class state{
		int r,c;
		long time;
		long mush;
		public state(int rr, int cc, long tt, long mm) {
			r=rr;
			c=cc;
			time=tt;
			mush=mm;
		}
	}

	
	static class JS{
		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 JS() {
			in = new BufferedInputStream(System.in, BS);
		}
		
		public JS(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() {
		    while(c!='.'&&c!='-'&&(c <'0' || c>'9')) c = nextChar();
		    boolean neg = c=='-';
		    if(neg)c=nextChar();
		    boolean fl = c=='.';
		    double cur = nextLong();
		    if(fl) return neg ? -cur/num : cur/num;
		    if(c == '.') {
			double next = nextLong();
			return neg ? -cur-next/num : cur+next/num;
		    }
		    else return neg ? -cur : cur;
		}
		
		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;
			}
		}
	}
	
}
