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 codeforces
		{	
			public static void main(String[] args)
			{
				InputReader in = new InputReader(System.in);
				PrintWriter pw = new PrintWriter(System.out);
				
				int n = in.nextInt();
				long[] a = new long[n];
				long[] b = new long[n];
				
				for(int i=0;i<n;i++)
					a[i] = in.nextLong();
				
				for(int i=0;i<n;i++)
					b[i] = in.nextLong();
				
				long[] T = new long[2*n];
				long[] B = new long[2*n-2];
				long[] Z = new long[2*n];
				long[] Tsum = new long[2*n];
				long[] Bsum = new long[2*n-2];
				int j = 0;
				long max = Long.MIN_VALUE, sum = 0;
				
				if(n == 1)
					max = b[0];
				else
				{
					for(int i=0;i<2*n;i++)
					{
						if(i<n)
							T[i] = a[i];
						else
							T[i] = b[2*n-i-1];
						
						if(i>0 && i<2*n-1)
						{
							if(i<n)
								B[i-1] = b[i];
							else
								B[i-1] = a[2*n-i-1];
						}
						
						if(i%4==0)
							Z[i] = a[j];
						else if(i%4==1)
						{
							Z[i] = b[j];
							j++;
						}
						else if(i%4==2)
							Z[i] = b[j];
						else
						{
							Z[i] = a[j];
							j++;
						}
					}
					
					Tsum = Arrays.copyOf(T, 2*n);
					Bsum = Arrays.copyOf(B, 2*n-2);
					
					for(int i=0;i<2*n;i++)
					{
						if(i==0)
						{
							T[i] = 0;
							Z[i] = 0;
							B[i] = 0;
						}
						else
						{
							Tsum[i] += Tsum[i-1];
							T[i] = i*T[i] + T[i-1];
							Z[i] = i*Z[i] + Z[i-1];
							
							if(i<2*n-2)
							{
								Bsum[i] += Bsum[i-1];
								B[i] = i*B[i] + B[i-1];
							}
						}
					}
					
					for(int i=0;i<n+1;i++)
					{
						if(i==0)
						{
							sum = T[2*n-1];
						}
						else if(i==1)
						{
							sum = Z[i] + B[2*n-3] + (i+1)*Bsum[2*n-3];
						}
						else
						{
							sum = Z[2*i-1];
							
							if(i%2!=0)
							{
								sum += B[2*n-i-2] - B[i-2] + (i+1)*(Bsum[2*n-i-2] - Bsum[i-2]);
							}
							else
							{
								sum += T[2*n-i-1] - T[i-1] + i*(Tsum[2*n-i-1] - Tsum[i-1]);
							}
						}
						//pw.println(sum);
						max = Math.max(max, sum);
						sum = 0;
							
					}
				}
				
				pw.println(max);
				/*for(int i=0;i<2*n;i++)
					pw.print(T[i]+" ");
				
pw.println();
				for(int i=0;i<2*n-2;i++)
					pw.print(Bsum[i]+" ");
				
pw.println();
				for(int i=0;i<2*n;i++)
					pw.print(Z[i]+" ");*/
				
				
				
				
				pw.flush();
				pw.close();
			}
			
			static class pair implements Comparable<pair>
			{
				Integer x, y;
				pair(int x,int y)
				{
					this.x=x;
					this.y=y;
				}
				
				public int compareTo(pair o) {
					int result = x.compareTo(o.x);
					if(result==0)
						result = y.compareTo(o.y);
					
					return result;
				}  
				
				public String toString()
				{
					return x+" "+y;
				}
				
				public boolean equals(Object o)
				{
					if (o instanceof pair)
				    {
						pair p = (pair)o;
						return p.x == x && p.y == y ;
					}
					return false;
				}
				
				public int hashCode()
				{
					return new Long(x).hashCode()*31 + new Long(y).hashCode();
				}
			}
			
			static class InputReader 
			{
				 
				private final InputStream stream;
				private final byte[] buf = new byte[8192];
				private int curChar, snumChars;
				private SpaceCharFilter filter;
		 
				public InputReader(InputStream stream) 
				{
					this.stream = stream;
				}
		 
				public int snext() 
				{
					if (snumChars == -1)
						throw new InputMismatchException();
					if (curChar >= snumChars) 
					{
						curChar = 0;
						try 
						{
							snumChars = stream.read(buf);
						} 
						catch (IOException e) 
						{
							throw new InputMismatchException();
						}
						if (snumChars <= 0)
							return -1;
					}
					return buf[curChar++];
				}
		 
				public int nextInt() 
			    {
					int c = snext();
					while (isSpaceChar(c)) 
					{
						c = snext();
					}
					int sgn = 1;
					if (c == '-')
				    {
						sgn = -1;
						c = snext();
					}
					int res = 0;
					do 
					{
						if (c < '0' || c > '9')
							throw new InputMismatchException();
						res *= 10;
						res += c - '0';
						c = snext();
					} while (!isSpaceChar(c));
					return res * sgn;
				}
		 
				public long nextLong()
			    {
					int c = snext();
					while (isSpaceChar(c)) 
					{
						c = snext();
					}
					int sgn = 1;
					if (c == '-') 
					{
						sgn = -1;
						c = snext();
					}
					long res = 0;
					do 
					{
						if (c < '0' || c > '9')
							throw new InputMismatchException();
						res *= 10;
						res += c - '0';
						c = snext();
					} while (!isSpaceChar(c));
					return res * sgn;
				}
		 
				public int[] nextIntArray(int n) 
				{
					int a[] = new int[n];
					for (int i = 0; i < n; i++) 
					{
						a[i] = nextInt();
					}
					return a;
				}
		 
				public String readString()
			    {
					int c = snext();
					while (isSpaceChar(c)) 
					{
						c = snext();
					}
					StringBuilder res = new StringBuilder();
					do 
					{
						res.appendCodePoint(c);
						c = snext();
					} while (!isSpaceChar(c));
					return res.toString();
				}
		 
				public String nextLine() 
				{
					int c = snext();
					while (isSpaceChar(c))
						c = snext();
					StringBuilder res = new StringBuilder();
					do 
					{
						res.appendCodePoint(c);
						c = snext();
					} while (!isEndOfLine(c));
					return res.toString();
				}
		 
				public boolean isSpaceChar(int c) 
				{
					if (filter != null)
						return filter.isSpaceChar(c);
					return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
				}
		 
				private boolean isEndOfLine(int c) 
				{
					return c == '\n' || c == '\r' || c == -1;
				}
		 
				public interface SpaceCharFilter
			    {
					public boolean isSpaceChar(int ch);
				}
			}
			
			static class CodeX {
	        public static void sort(long arr[]) {
	            merge_sort(arr, 0, arr.length - 1);
	        }
	
	        private static void merge_sort(long A[], long start, long end) {
	            if (start < end) {
	                long mid = (start + end) / 2;
	                merge_sort(A, start, mid);
	                merge_sort(A, mid + 1, end);
	                merge(A, start, mid, end);
	            }
	
	        }
	
	        private static void merge(long A[], long start,long mid, long end) {
	            long p = start, q = mid + 1;
	            long Arr[] = new long[(int)(end - start + 1)];
	            long k = 0;
	
	            for (int i = (int)start; i <= end; i++) {
	                if (p > mid)
	                    Arr[(int)k++] = A[(int)q++];
	
	                else if (q > end)
	                    Arr[(int)k++] = A[(int)p++];
	
	                else if (A[(int)p] < A[(int)q])
	                    Arr[(int)k++] = A[(int)p++];
	
	                else
	                    Arr[(int)k++] = A[(int)q++];
	            }
	            for (int i = 0; i < k; i++) {
	                A[(int)start++] = Arr[i];
	            }
	
	        }
	
	    }
		}	
			