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.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;

public class Problem {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskF solver = new TaskF();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskF {

		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int n = in.nextInt();
			long[][] a = new long[2][n];
			for (int i = 0; i < n; i++) {
				a[0][i] = in.nextLong();
			}
			for (int i = 0; i < n; i++) {
				a[1][i] = in.nextLong();
			}
			long[][] z = new long[2][n];

			int zn = 2 * n;
			long c = 0;
			int i = 0, j = 0;
			long l = 0;
			while (zn > 0) {
				z[i][j] = l + c * a[i][j];
				l = z[i][j];
				if (zn % 2 == 0) {
					i = (i + 1) % 2;
				} else {
					j++;
				}
				c++;
				zn--;
			}

			long tc = 0;
			long ta = 0;
			long tot = 0;
			int t = 0;
			for (int x = 0; x < n; x++) {
				tc += t * a[0][x];
				ta += t * a[1][x];
				tot += a[0][x];
				t++;
			}

			for (int x = n - 1; x >= 0; x--) {
				tc += t * a[1][x];
				ta += t * a[0][x];
				tot += a[1][x];
				t++;
			}

			int y = 0;
			long max = tc;
			tot -= a[0][0];
			tot -= a[1][0];

			ta -= (2 * n - 1) * a[0][0];
			tc -= (2 * n - 1) * a[1][0];

			int q = 1, r = 2 * n - 2;
			for (int x = 1; x < n; x++) {
				long val = 0;
				if (y == 0) {
					val = z[1][x - 1] + (ta + (q * tot));
				} else {
					val = z[0][x - 1] + (tc + (q * tot));
				}
				max = Math.max(max, val);

				tot -= a[0][x];
				tot -= a[1][x];

				ta -= q * a[1][x];
				ta -= r * a[0][x];

				tc -= q * a[0][x];
				tc -= r * a[1][x];

				y = (y + 1) % 2;

				q++;
				r--;
			}
			out.println(max);
		}
	}

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

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		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 int nextInt() {
			return Integer.parseInt(next());
		}

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

	}
}