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.awt.List;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.util.Locale;
import java.util.TimeZone;

public class C {

	public static void main(String[] args) {
		Locale.setDefault(Locale.US);
		InputStream inputstream = System.in;
		OutputStream outputstream = System.out;
		FastReader in = new FastReader(inputstream);
		PrintWriter out = new PrintWriter(outputstream);
		TaskA solver = new TaskA();
		// int testcase = in.ni();
		for (int i = 0; i < 1; i++)
			solver.solve(i, in, out);
		out.close();

	}

}

class TaskA {

	public void solve(int testnumber, FastReader in, PrintWriter out) {
		
		
		
		int n = in.ni();
		long[] a = new long[n];
		long[] b = new long[n];

		for (int i = 0; i < n; i++) {
			a[i] = Long.parseLong(in.ns());
		}

		for (int i = 0; i < n; i++) {
			b[i] = Long.parseLong(in.ns());
		}

		long sa_right[] = new long[n];
		long sb_right[] = new long[n];
		
		sa_right[n - 1] = a[n - 1];
		sb_right[n - 1] = b[n - 1];
		
		for (int i = n - 2; i >= 0; i--) {
			
			sa_right[i] = sa_right[i + 1] + a[i];
			
			sb_right[i] = sb_right[i + 1] + b[i];
		}

		long pa_right[] = new long[n];
		long pb_right[] = new long[n];

		long pa_left[] = new long[n];
		long pb_left[] = new long[n];

		pa_right[n - 1] = a[n - 1];
		pa_left[n - 1] = a[n - 1];
		
		pb_right[n - 1] = b[n - 1];
		pb_left[n - 1] = b[n - 1];

		for (int i = n - 2; i >= 0; i--) {
			
			pa_right[i] = pa_right[i + 1] + sa_right[i];
			pb_right[i] = pb_right[i + 1] + sb_right[i];
			
			pa_left[i] = pa_left[i + 1] + (n - i) * a[i];
			pb_left[i] = pb_left[i+1] + (n - i) * b[i];
		}

		long max = 0;
		long current = 0;

		for (int i = 0; i < n; i++) {
			long res = 0;
			if (i % 2 == 0) {
				res = ((2 * i - 1) * sa_right[i] + pa_right[i] + (n + i - 1)
						* sb_right[i] + pb_left[i]);
			} else {
				res = ((2 * i - 1) * sb_right[i] + pb_right[i] + (n + i - 1)
						* sa_right[i] + pa_left[i]);
			}

			max = Math.max(current + res, max);

			if (i % 2 == 0) {
				current += a[i] * (2 * i) + b[i] * (2 * i + 1);
			} else {
				current += b[i] * (2 * i) + a[i] * (2 * i + 1);
			}
		}

		out.println(max);
	}
}

class FastReader {
	public InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public FastReader(InputStream stream) {
		this.stream = stream;
	}

	public FastReader() {

	}

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

	public int ni() {
		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 String ns() {
		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 boolean isSpaceChar(int c) {
		if (filter != null) {
			return filter.isSpaceChar(c);
		}
		return isWhitespace(c);
	}

	public static boolean isWhitespace(int c) {
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

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

	public String next() {
		return ns();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}

}