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 static java.lang.Math.*;

import java.util.*;

public class C {

	public Object solve() {
		int N = sc.nextInt();
		long [] A = sc.nextLongs();
		long [] B = sc.nextLongs();

		long [][] H = new long [N][2];
		H[0][1] = B[0];

		for (int c : rep(1, N))
			if (c % 2 == 0) {
				H[c][0] = H[c-1][0] + (2*c) * A[c];
				H[c][1] = H[c][0] + (2*c+1) * B[c];
			}
			else {
				H[c][1] = H[c-1][1] + (2*c) * B[c];
				H[c][0] = H[c][1] + (2*c + 1) * A[c];
			}

		long [][] T = new long [N][2];
		long [] U = new long [N];

		for (int c : rep(N)) {
			T[0][0] += c * A[c] + (2*N - 1 - c) * B[c];
			T[0][1] += c * B[c] + (2*N - 1 - c) * A[c];
			U[c] = (c == 0 ? 0 : U[c-1]) + A[c] + B[c];
		}

		for (int c : rep(N-1)) {
			T[c+1][0] = T[c][0] - (2*c) * A[c] - (2*N - 1) * B[c] + (U[N-1] - U[c]);
			T[c+1][1] = T[c][1] - (2*c) * B[c] - (2*N - 1) * A[c] + (U[N-1] - U[c]);
		}

		long res = max(T[0][0], H[N-1][N%2]);
		for (int c : rep(1, N))
			res = max(res, H[c-1][c%2] + T[c][c%2]);

		exit(res);
		return null;
	}

	private static final boolean ONE_TEST_CASE = true;

	private static void init() {
	}

	private static Iterable<Integer> rep (int N) { return rep(0, N); }
	private static Iterable<Integer> rep (final int S, final int T) { return new Iterable<Integer>() { public Iterator<Integer> iterator() { return S < T ? java.util.stream.IntStream.range(S,  T).iterator() : Collections.emptyIterator(); } }; }
	////////////////////////////////////////////////////////////////////////////////////
	private static IOUtils.MyScanner sc = new IOUtils.MyScanner();
	private static Object print (Object o, Object ... A) { IOUtils.print(o, A); return null; }
	private static Object exit (Object o, Object ... A) { print(o, A); IOUtils.exit(); return null; }
	private static class IOUtils {
		public static class MyScanner {
			public String next() { newLine(); return line[index++]; }
			public int nextInt() { return Integer.parseInt(next()); }
			public String nextLine() { line = null; return readLine(); }
			public String [] nextStrings() { return split(nextLine()); }
			public long[] nextLongs() { return nextStream().mapToLong(Long::parseLong).toArray(); }
			//////////////////////////////////////////////
			private boolean eol() { return index == line.length; }
			private String readLine() {
				try {
					return r.readLine();
				} catch (Exception e) {
					throw new Error (e);
				}
			}
			private final java.io.BufferedReader r;
			private MyScanner () { this(new java.io.BufferedReader(new java.io.InputStreamReader(System.in))); }
			private MyScanner (java.io.BufferedReader r) {
				try {
					this.r = r;
					while (!r.ready())
						Thread.sleep(1);
					start();
				} catch (Exception e) {
					throw new Error(e);
				}
			}
			private String [] line;
			private int index;
			private void newLine() {
				if (line == null || eol()) {
					line = split(readLine());
					index = 0;
				}
			}
			private java.util.stream.Stream<String> nextStream() { return java.util.Arrays.stream(nextStrings()); }
			private String [] split(String s) { return s.length() > 0 ? s.split(" ") : new String [0]; }
		}
		private static String build(Object o, Object ... A) { return buildDelim(" ", o, A); }
		private static String buildDelim(String delim, Object o, Object ... A) {
			StringBuilder b = new StringBuilder();
			append(b, o, delim);
			for (Object p : A)
				append(b, p, delim);
			return b.substring(delim.length());
		}
		//////////////////////////////////////////////////////////////////////////////////
		private static void start() { if (t == 0) t = millis(); }
		private static void append(java.util.function.Consumer<Object> f, java.util.function.Consumer<Object> g, final Object o) {
			if (o.getClass().isArray()) {
				int len = java.lang.reflect.Array.getLength(o);
				for (int i = 0; i < len; ++i)
					f.accept(java.lang.reflect.Array.get(o, i));
			}
			else if (o instanceof Iterable<?>)
				((Iterable<?>)o).forEach(f::accept);
			else
				g.accept(o instanceof Double ? new java.text.DecimalFormat("#.#########").format(o) : o);
		}
		private static void append(final StringBuilder b, Object o, final String delim) {
			append(x -> { append(b, x, delim); }, x -> b.append(delim).append(x), o);
		}
		private static java.io.PrintWriter pw = new java.io.PrintWriter(System.out);
		private static Object print(Object o, Object ... A) { pw.println(build(o, A)); return null; }
		private static void err(Object o, Object ... A) { System.err.println(build(o, A)); }
		private static boolean PRINT;
		private static void write(Object o) {
			err(o, '(', time(), ')');
			if (PRINT)
				pw.println(o);
		}
		private static void exit() {
			IOUtils.pw.close();
			System.out.flush();
			err("------------------");
			err(time());
			System.exit(0);
		}
		private static long t;
		private static long millis() { return System.currentTimeMillis(); }
		private static String time() { return "Time: " + (millis() - t) / 1000.0; }
		private static void run(int N) {
			try { PRINT = System.getProperties().containsKey("PRINT"); }
			catch (Throwable t) {}

			for (int n = 1; n <= N; ++n) {
				Object res = new C().solve();
				if (res != null)
					write("Case #" + n + ": " + build(res));
			}
			exit();
		}
	}
	public static void main(String[] args) {
		init();
		int N = ONE_TEST_CASE ? 1 : sc.nextInt();
		IOUtils.run(N);
	}
}
