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

import static java.util.Arrays.fill;
import static java.lang.Math.*;
import static java.util.Arrays.sort;
import static java.util.Collections.sort;

public class C {

	public static int mod = 1000000007;
	public static long INF = (1L << 60);
	static FastScanner2 in = new FastScanner2();
	static OutputWriter out = new OutputWriter(System.out);

	public static void main(String[] args) {

		int n=in.nextInt();
		long[] a=new long[n+1];
		long[] b=new long[n+1];
		long[] psum1=new long[n+1];
		long[] psum2=new long[n+1];
		for(int i=0;i<n;i++)
		{
			a[i]=in.nextLong();
			if(i==0)
			{
				psum1[i]=a[i];
			}
			else
			{
				psum1[i]=psum1[i-1]+a[i];
			}
		}
		for(int i=0;i<n;i++)
		{
			b[i]=in.nextLong();
			if(i==0)
			{
				psum2[i]=b[i];
			}
			else
			{
				psum2[i]=psum2[i-1]+b[i];
			}
		}
		long[] asum=new long[n+2];
		long[] rasum=new long[n+2];
		long[] bsum=new long[n+2];
		long[] rbsum=new long[n+2];
		for(int i=1;i<n;i++)
		{
			asum[i]=asum[i-1]+(i)*a[i];
			bsum[i]=bsum[i-1]+(i)*b[i];
		}
		for(int i=n-1;i>=0;i--)
		{
			rasum[i]=rasum[i+1]+(n-1-i)*a[i];
			rbsum[i]=rbsum[i+1]+(n-1-i)*b[i];
		}
		long ans1=0,ans2=0,tempans=0,ans=0;
		long mul=0;
		tempans=asum[n-1]+n*psum2[n-1]+rbsum[0];
		ans=max(ans, tempans);
		tempans=0;
		for(int i=0;i<n;i++)
		{
			if(i%2==0)
			{
				ans1+=(mul++)*a[i];
				ans1+=(mul++)*b[i];
				//tr(mul);
				tempans=ans1+((mul)*(psum2[n-1]-psum2[i]))+(bsum[n-1]-bsum[i]);
				long tmul=mul+(n-1-(i+1));
				tempans+=(tmul)*(psum1[n-1]-psum1[i])+rasum[i+1];
				ans=max(ans, tempans);
				//tr(ans+" here "+i+" "+tempans+" "+ans1);
				tempans=0;
			}
			else
			{
				ans1+=(mul++)*b[i];
				ans1+=(mul++)*a[i];
				tempans=ans1+(mul)*(psum1[n-1]-psum1[i])+(asum[n-1]-asum[i]);
				long tmul=mul+(n-1-(i+1));
				tempans+=(tmul)*(psum2[n-1]-psum2[i])+rbsum[i+1];
				ans=max(ans, tempans);
				//tr(ans+" here "+i+" "+tempans+" "+ans1);
				tempans=0;
			}
			
		}
		out.println(ans);
		out.close();

	}

	static class FastScanner2 {
		private byte[] buf = new byte[1024];
		private int curChar;
		private int snumChars;

		public int read() {
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = System.in.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public String nextLine() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public String nextString() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public long nextLong() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int nextInt() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int[] nextIntArray(int n) {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = nextInt();
			}
			return arr;
		}

		public long[] nextLongArray(int n) {
			long[] arr = new long[n];
			for (int i = 0; i < n; i++) {
				arr[i] = nextLong();
			}
			return arr;
		}

		private boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream inputstream) {
			reader = new BufferedReader(new InputStreamReader(inputstream));
			tokenizer = null;
		}

		public String nextLine() {
			String fullLine = null;
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					fullLine = reader.readLine();
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
				return fullLine;
			}
			return fullLine;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public int[] nextIntArray(int n) {
			int a[] = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = nextInt();
			}
			return a;
		}

		public long[] nextLongArray(int n) {
			long a[] = new long[n];
			for (int i = 0; i < n; i++) {
				a[i] = nextLong();
			}
			return a;
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}
	}

	static class OutputWriter {
		private final PrintWriter writer;

		public OutputWriter(OutputStream outputStream) {
			writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
		}

		public OutputWriter(Writer writer) {
			this.writer = new PrintWriter(writer);
		}

		public void print(Object... objects) {
			for (int i = 0; i < objects.length; i++) {
				if (i != 0)
					writer.print(' ');
				writer.print(objects[i]);
			}
		}

		public void println(Object... objects) {
			print(objects);
			writer.println();
		}

		public void close() {
			writer.close();
		}

		public void flush() {
			writer.flush();
		}
	}

	private static boolean oj = System.getProperty("ONLINE_JUDGE") != null;

	private static void debug(Object... o) {
		if (!oj)
			System.out.println(Arrays.deepToString(o));
	}

	private static void tr(Object... o) {
		if (!oj)
			System.out.println(Arrays.deepToString(o));
	}
}


